mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
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:
committed by
Nathan Sobo
parent
46eb861f84
commit
c2c7241eda
@@ -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) {
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user