From 3d55df0dee63eacdf8dc5598295b108c2fcf7979 Mon Sep 17 00:00:00 2001 From: Oj Date: Fri, 10 Dec 2021 20:45:54 +0000 Subject: [PATCH] [Splash] Add better webcontentssend error handling and checking --- src/splash/splashScreen.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/splash/splashScreen.js b/src/splash/splashScreen.js index db9cc83..9aaa35e 100644 --- a/src/splash/splashScreen.js +++ b/src/splash/splashScreen.js @@ -69,8 +69,12 @@ exports.events = events; function webContentsSend(win, event, ...args) { // log('Splash', `Sending to webcontents:`, event, args); - if (win != null && win.webContents != null) { - win.webContents.send(`DISCORD_${event}`, ...args); + if (splashWindow != null && !splashWindow.isDestroyed() && !splashWindow.webContents.isDestroyed()) { + try { + win.webContents.send(`DISCORD_${event}`, ...args); + } catch (e) { // Mostly ignore, probably just destroyed + log('Splash', 'Failed to send to webcontents'); + } } } @@ -407,12 +411,10 @@ function stopUpdateTimeout() { } function updateSplashState(event) { - if (splashWindow != null && !splashWindow.isDestroyed() && !splashWindow.webContents.isDestroyed()) { - webContentsSend(splashWindow, 'SPLASH_UPDATE_STATE', { - status: event, - ...splashState - }); - } + webContentsSend(splashWindow, 'SPLASH_UPDATE_STATE', { + status: event, + ...splashState + }); } function launchSplashWindow(startMinimized) {