MOBILE-2478 desktop: Prevent errors when calling close in closed windows

main
Dani Palou 2018-07-23 10:37:02 +02:00
parent 4b45b3120b
commit efb5db4f47
2 changed files with 15 additions and 5 deletions

View File

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

View File

@ -94,7 +94,16 @@ export class InAppBrowserObjectMock {
* Close the window.
*/
close(): void {
if (this.window.isDestroyed()) {
// Window already closed, nothing to do.
return;
}
try {
this.window.close();
} catch (ex) {
// Ignore errors.
}
}
/**