From dd453f72bd383bf17c46ab65edd4e0d7646bfb6e Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Wed, 16 Aug 2017 11:51:10 +0200 Subject: [PATCH] fix mac os issue of darwinForceToQuit not being defined --- electron/main-window.js | 8 +++++--- electron/main.js | 9 ++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/electron/main-window.js b/electron/main-window.js index 1e32dbcab5..5cc195a8a4 100644 --- a/electron/main-window.js +++ b/electron/main-window.js @@ -5,12 +5,14 @@ const url = require('url'); const open = require('open'); let mainWin; + function createWindow(params) { const IS_DEV = params.IS_DEV; const ICONS_FOLDER = params.ICONS_FOLDER; const IS_MAC = params.IS_MAC; const quitApp = params.quitApp; const app = params.app; + const nestedWinParams = params.nestedWinParams; let frontendDir; @@ -37,7 +39,7 @@ function createWindow(params) { // Open the DevTools. //mainWin.webContents.openDevTools(); - initWinEventListeners(app, IS_MAC); + initWinEventListeners(app, IS_MAC, nestedWinParams); if (IS_MAC) { createMenu(quitApp); @@ -46,7 +48,7 @@ function createWindow(params) { return mainWin; } -function initWinEventListeners(app, IS_MAC) { +function initWinEventListeners(app, IS_MAC, nestedWinParams) { // open new window links in browser mainWin.webContents.on('new-window', function (event, url) { event.preventDefault(); @@ -56,7 +58,7 @@ function initWinEventListeners(app, IS_MAC) { mainWin.on('close', function (event) { // handle darwin if (IS_MAC) { - if (!darwinForceQuit) { + if (!nestedWinParams.isDarwinForceQuit) { event.preventDefault(); mainWin.hide(); } diff --git a/electron/main.js b/electron/main.js index 123b60611d..db0ca512b3 100644 --- a/electron/main.js +++ b/electron/main.js @@ -25,7 +25,7 @@ const app = electron.app; let mainWin; let lastIdleTime; let currentIdleStart; -let darwinForceQuit = false; +let nestedWinParams = { isDarwinForceQuit: false }; // keep app active to keep time tracking running powerSaveBlocker.start('prevent-app-suspension'); @@ -48,7 +48,7 @@ if (shouldQuitBecauseAppIsAnotherInstance) { app.on('ready', createMainWin); app.on('ready', createIndicator); -app.on('activate', function () { +app.on('activate', function() { // On OS X it's common to re-create a window in the app when the // dock icon is clicked and there are no other windows open. if (mainWin === null) { @@ -65,7 +65,7 @@ app.on('ready', () => { app.on('before-quit', () => { // handle darwin if (IS_MAC) { - darwinForceQuit = true; + nestedWinParams.isDarwinForceQuit = true; } // un-register all shortcuts. @@ -110,6 +110,7 @@ function createIndicator() { ICONS_FOLDER, }); } + function createMainWin() { mainWin = mainWinMod.createWindow({ app, @@ -117,6 +118,7 @@ function createMainWin() { ICONS_FOLDER, IS_MAC, quitApp, + nestedWinParams }); } @@ -151,6 +153,7 @@ function showIdleDialog(idleTimeInMs) { function showApp() { showOrFocus(mainWin); } + function quitApp() { app.isQuiting = true; app.quit();