Destroy AtomEnvironment in beforeunload handler, not unload handler

See https://github.com/electron/electron/issues/7278

Signed-off-by: Nathan Sobo <nathan@github.com>
This commit is contained in:
Max Brunsfeld
2016-09-20 16:10:05 -07:00
committed by Nathan Sobo
parent 46eb861f84
commit c2c7241eda
2 changed files with 4 additions and 14 deletions

View File

@@ -327,9 +327,6 @@ describe('AtomApplication', function () {
assert.deepEqual(directories, [{type: 'FakeRemoteDirectory', path: remotePath}])
await window.saveState()
await evalInWebContents(window.browserWindow.webContents, function (sendBackToMainProcess) {
sendBackToMainProcess(atom.destroy())
})
await window.reload()
await focusWindow(window)
directories = await evalInWebContents(window.browserWindow.webContents, function (sendBackToMainProcess) {

View File

@@ -10,9 +10,7 @@ class WindowEventHandler
@reloadRequested = false
@subscriptions = new CompositeDisposable
@previousOnbeforeunloadHandler = @window.onbeforeunload
@window.onbeforeunload = @handleWindowBeforeunload
@addEventListener(@window, 'unload', @handleWindowUnload)
@addEventListener(@window, 'beforeunload', @handleWindowBeforeunload)
@addEventListener(@window, 'focus', @handleWindowFocus)
@addEventListener(@window, 'blur', @handleWindowBlur)
@@ -64,7 +62,6 @@ class WindowEventHandler
bindCommandToAction('core:cut', 'cut')
unsubscribe: ->
@window.onbeforeunload = @previousOnbeforeunloadHandler
@subscriptions.dispose()
on: (target, eventName, handler) ->
@@ -152,7 +149,7 @@ class WindowEventHandler
handleLeaveFullScreen: =>
@document.body.classList.remove("fullscreen")
handleWindowBeforeunload: =>
handleWindowBeforeunload: (event) =>
confirmed = @atomEnvironment.workspace?.confirmClose(windowCloseRequested: true)
if confirmed and not @reloadRequested and not @atomEnvironment.inSpecMode() and @atomEnvironment.getCurrentWindow().isWebViewFocused()
@atomEnvironment.hide()
@@ -161,14 +158,10 @@ class WindowEventHandler
@atomEnvironment.storeWindowDimensions()
if confirmed
@atomEnvironment.unloadEditorWindow()
@atomEnvironment.destroy()
else
@applicationDelegate.didCancelWindowUnload()
# Returning any non-void value stops the window from unloading
return true unless confirmed
handleWindowUnload: =>
@atomEnvironment.destroy()
event.returnValue = false
handleWindowToggleFullScreen: =>
@atomEnvironment.toggleFullScreen()