Do not trigger window-all-closed unless main window has been created
This commit is contained in:
parent
8ede54c925
commit
fe62d5c8ec
1 changed files with 10 additions and 3 deletions
13
main.js
13
main.js
|
@ -49,6 +49,7 @@ app.allowRendererProcessReuse = true;
|
||||||
// Keep a global reference of the window object, if you don't, the window will
|
// Keep a global reference of the window object, if you don't, the window will
|
||||||
// be closed automatically when the JavaScript object is garbage collected.
|
// be closed automatically when the JavaScript object is garbage collected.
|
||||||
let mainWindow;
|
let mainWindow;
|
||||||
|
let mainWindowCreated = false;
|
||||||
let loadingWindow;
|
let loadingWindow;
|
||||||
|
|
||||||
function getMainWindow() {
|
function getMainWindow() {
|
||||||
|
@ -313,6 +314,7 @@ async function createWindow() {
|
||||||
|
|
||||||
// Create the browser window.
|
// Create the browser window.
|
||||||
mainWindow = new BrowserWindow(windowOptions);
|
mainWindow = new BrowserWindow(windowOptions);
|
||||||
|
mainWindowCreated = true;
|
||||||
setupSpellChecker(mainWindow, locale.messages);
|
setupSpellChecker(mainWindow, locale.messages);
|
||||||
if (!usingTrayIcon && windowConfig && windowConfig.maximized) {
|
if (!usingTrayIcon && windowConfig && windowConfig.maximized) {
|
||||||
mainWindow.maximize();
|
mainWindow.maximize();
|
||||||
|
@ -999,13 +1001,18 @@ app.on('before-quit', () => {
|
||||||
|
|
||||||
// Quit when all windows are closed.
|
// Quit when all windows are closed.
|
||||||
app.on('window-all-closed', () => {
|
app.on('window-all-closed', () => {
|
||||||
|
console.log('main process handling window-all-closed');
|
||||||
// On OS X it is common for applications and their menu bar
|
// On OS X it is common for applications and their menu bar
|
||||||
// to stay active until the user quits explicitly with Cmd + Q
|
// to stay active until the user quits explicitly with Cmd + Q
|
||||||
if (
|
const shouldAutoClose =
|
||||||
process.platform !== 'darwin' ||
|
process.platform !== 'darwin' ||
|
||||||
config.environment === 'test' ||
|
config.environment === 'test' ||
|
||||||
config.environment === 'test-lib'
|
config.environment === 'test-lib';
|
||||||
) {
|
|
||||||
|
// Only automatically quit if the main window has been created
|
||||||
|
// This is necessary because `window-all-closed` can be triggered by the
|
||||||
|
// "optimizing application" window closing
|
||||||
|
if (shouldAutoClose && mainWindowCreated) {
|
||||||
app.quit();
|
app.quit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue