diff --git a/desktop/electron.js b/desktop/electron.js index 557ae4cfe..51087a40d 100644 --- a/desktop/electron.js +++ b/desktop/electron.js @@ -184,10 +184,11 @@ ipcMain.on('openItem', (event, path) => { }); ipcMain.on('closeSecondaryWindows', () => { - var windows = BrowserWindow.getAllWindows(); - for (var i = 0; i < windows.length; i++) { - if (!mainWindow || windows[i].id != mainWindow.id) { - windows[i].close(); + const windows = BrowserWindow.getAllWindows(); + for (let i = 0; i < windows.length; i++) { + const win = windows[i]; + if (!win.isDestroyed() && (!mainWindow || win.id != mainWindow.id)) { + win.close(); } } }); diff --git a/src/core/emulator/classes/inappbrowserobject.ts b/src/core/emulator/classes/inappbrowserobject.ts index 0af54081a..95b23898f 100644 --- a/src/core/emulator/classes/inappbrowserobject.ts +++ b/src/core/emulator/classes/inappbrowserobject.ts @@ -94,7 +94,16 @@ export class InAppBrowserObjectMock { * Close the window. */ close(): void { - this.window.close(); + if (this.window.isDestroyed()) { + // Window already closed, nothing to do. + return; + } + + try { + this.window.close(); + } catch (ex) { + // Ignore errors. + } } /**