From 3431997315e0e3591409ac66c06a7be289f027d2 Mon Sep 17 00:00:00 2001 From: smolgumball Date: Sat, 29 Jan 2022 17:58:09 -0700 Subject: [PATCH] fix: electron `windowTracker` error when reloading and killing scripts --- electron/windowTracker.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/electron/windowTracker.js b/electron/windowTracker.js index 563822177..c4c987ae1 100644 --- a/electron/windowTracker.js +++ b/electron/windowTracker.js @@ -29,6 +29,11 @@ const windowTracker = (windowName) => { }; const saveState = debounce(() => { + if (!window || window.isDestroyed()) { + log.silly(`Saving window state failed because window is not available`); + return; + } + if (!windowState.isMaximized) { windowState = window.getBounds(); } @@ -41,7 +46,7 @@ const windowTracker = (windowName) => { const track = (win) => { window = win; - ['resize', 'move', 'close'].forEach((event) => { + ["resize", "move", "close"].forEach((event) => { win.on(event, saveState); }); };