diff --git a/spec/atom-environment-spec.coffee b/spec/atom-environment-spec.coffee index 23f8e0e51..3e6536681 100644 --- a/spec/atom-environment-spec.coffee +++ b/spec/atom-environment-spec.coffee @@ -243,6 +243,21 @@ describe "AtomEnvironment", -> atomEnvironment.destroy() + describe "::destroy()", -> + it "does not throw exceptions when unsubscribing from ipc events (regression)", -> + configDirPath = temp.mkdirSync() + fakeDocument = { + addEventListener: -> + removeEventListener: -> + head: document.createElement('head') + body: document.createElement('body') + } + atomEnvironment = new AtomEnvironment({applicationDelegate: atom.applicationDelegate, window, document: fakeDocument}) + spyOn(atomEnvironment.packages, 'getAvailablePackagePaths').andReturn [] + atomEnvironment.startEditorWindow() + atomEnvironment.unloadEditorWindow() + atomEnvironment.destroy() + describe "::openLocations(locations) (called via IPC from browser process)", -> beforeEach -> spyOn(atom.workspace, 'open') diff --git a/src/application-delegate.coffee b/src/application-delegate.coffee index 1999c6e83..1e05b3dbb 100644 --- a/src/application-delegate.coffee +++ b/src/application-delegate.coffee @@ -138,7 +138,7 @@ class ApplicationDelegate ipc.on('message', outerCallback) new Disposable -> - ipc.removeEventListener('message', outerCallback) + ipc.removeListener('message', outerCallback) onUpdateAvailable: (callback) -> outerCallback = (message, detail) -> @@ -147,17 +147,17 @@ class ApplicationDelegate ipc.on('message', outerCallback) new Disposable -> - ipc.removeEventListener('message', outerCallback) + ipc.removeListener('message', outerCallback) onApplicationMenuCommand: (callback) -> ipc.on('command', callback) new Disposable -> - ipc.removeEventListener('command', callback) + ipc.removeListener('command', callback) onContextMenuCommand: (callback) -> ipc.on('context-command', callback) new Disposable -> - ipc.removeEventListener('context-command', callback) + ipc.removeListener('context-command', callback) didCancelWindowUnload: -> ipc.send('did-cancel-window-unload') diff --git a/src/atom-environment.coffee b/src/atom-environment.coffee index 938010607..ac76daf04 100644 --- a/src/atom-environment.coffee +++ b/src/atom-environment.coffee @@ -623,7 +623,7 @@ class AtomEnvironment extends Model @registerDefaultTargetForKeymaps() @packages.loadPackages() - + @loadStateSync() @document.body.appendChild(@views.getView(@workspace)) @watchProjectPath() diff --git a/src/initialize-application-window.coffee b/src/initialize-application-window.coffee index e301a20d0..57aa33ce0 100644 --- a/src/initialize-application-window.coffee +++ b/src/initialize-application-window.coffee @@ -24,7 +24,6 @@ module.exports = ({blobStore}) -> }) atom.displayWindow() - atom.loadStateSync() atom.startEditorWindow() # Workaround for focus getting cleared upon window creation