Skip to content

Commit

Permalink
electron - properly await on exit
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Feb 12, 2020
1 parent a66b0a9 commit d9796e1
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -574,12 +574,15 @@ export class LifecycleMainService extends Disposable implements ILifecycleMainSe
(async () => {
for (const window of BrowserWindow.getAllWindows()) {
if (window && !window.isDestroyed()) {
let whenWindowClosed: Promise<void>;
if (window.webContents && !window.webContents.isDestroyed()) {
await new Promise(c => window.once('closed', c));
window.destroy();
whenWindowClosed = new Promise(c => window.once('closed', c));
} else {
window.destroy();
whenWindowClosed = Promise.resolve();
}

window.destroy();
await whenWindowClosed;
}
}
})()
Expand Down

0 comments on commit d9796e1

Please sign in to comment.