Merge pull request #2875 from smolgumball/fix-electron-crash-during-reload

fix: electron `windowTracker` crash when reloading and killing scripts
This commit is contained in:
hydroflame 2022-03-01 11:25:31 -05:00 committed by GitHub
commit fb4812b530
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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);
});
};