Use beforeunload instead of unload

unload is asynchronous in Chrome 36 and so saving the state while
reloading may not happen before the state is read on the new render
process.
This commit is contained in:
Kevin Sawicki 2014-08-11 11:22:37 -07:00
parent 8dffb45fd7
commit 16d2e41309
3 changed files with 7 additions and 5 deletions

View File

@ -28,7 +28,7 @@ atom.keymaps.loadBundledKeymaps()
keyBindingsToRestore = atom.keymaps.getKeyBindings()
$(window).on 'core:close', -> window.close()
$(window).on 'unload', ->
$(window).on 'beforeunload', ->
atom.storeWindowDimensions()
atom.saveSync()
$('html,body').css('overflow', 'auto')

View File

@ -311,10 +311,10 @@ class Atom extends Model
@requireUserInitScript()
@menu.update()
$(window).on 'unload', =>
$(window).on 'beforeunload', =>
$(document.body).css('visibility', 'hidden')
@unloadEditorWindow()
false
null
@displayWindow()

View File

@ -37,11 +37,13 @@ class WindowEventHandler
@reloadRequested = false
confirmed
@subscribe $(window), 'blur unload', ->
@subscribe $(window), 'blur beforeunload', ->
atom.storeDefaultWindowDimensions()
null
@subscribe $(window), 'unload', ->
@subscribe $(window), 'beforeunload', ->
atom.storeWindowDimensions()
null
@subscribeToCommand $(window), 'window:toggle-full-screen', -> atom.toggleFullScreen()