From 8b0f0a2323532471b0b8726cb71c0530ad54400c Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Wed, 18 May 2016 15:41:20 -0700 Subject: [PATCH] fix(quit): Booleans on globals are not exposed through remote properly --- src/browser/application.es6 | 4 ++++ src/browser/nylas-window.coffee | 3 +-- src/window-event-handler.coffee | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/browser/application.es6 b/src/browser/application.es6 index c61939d07..6b9bad3c0 100644 --- a/src/browser/application.es6 +++ b/src/browser/application.es6 @@ -72,6 +72,10 @@ export default class Application extends EventEmitter { return this.windowManager.get(WindowManager.MAIN_WINDOW).browserWindow; } + isQuitting() { + return this.quitting; + } + temporaryInitializeDisabledPackages() { if (this.config.get('core.disabledPackagesInitialized')) { return; diff --git a/src/browser/nylas-window.coffee b/src/browser/nylas-window.coffee index 6d2d23e6a..affa53241 100644 --- a/src/browser/nylas-window.coffee +++ b/src/browser/nylas-window.coffee @@ -148,8 +148,7 @@ class NylasWindow # # This uses the DOM's `beforeunload` event. @browserWindow.on 'close', (event) => - if @neverClose and !global.application.quitting - + if @neverClose and !global.application.isQuitting() # For neverClose windows (like the main window) simply hide and # take out of full screen. event.preventDefault() diff --git a/src/window-event-handler.coffee b/src/window-event-handler.coffee index 3745cd82e..b6a8937be 100644 --- a/src/window-event-handler.coffee +++ b/src/window-event-handler.coffee @@ -37,6 +37,8 @@ class WindowEventHandler window.onbeforeunload = => # Don't hide the window here if we don't want the renderer process to be # throttled in case more work needs to be done before closing + + # In Electron, returning false cancels the close. return @runUnloadCallbacks() window.onunload = => @@ -122,7 +124,7 @@ class WindowEventHandler runUnloadFinished: -> {remote} = require('electron') _.defer -> - if remote.getGlobal('application').quitting + if remote.getGlobal('application').isQuitting() remote.app.quit() else NylasEnv.close()