mirror of
https://github.com/atom/atom.git
synced 2026-01-23 22:08:08 -05:00
Only deactivate the RootView once during shutdown
Previously window.shutdown() was called multiple times if window.close() was called since the shutdown handler was also fired in the native window controller. This prevented proper serialization of the RootView from occurring when then window was closed via meta-w or meta-W since it was called a second time when already empty of packages and editors.
This commit is contained in:
@@ -2,8 +2,11 @@ $ = require 'jquery'
|
||||
fs = require 'fs'
|
||||
|
||||
describe "Window", ->
|
||||
[rootView] = []
|
||||
|
||||
beforeEach ->
|
||||
window.attachRootView(require.resolve('fixtures'))
|
||||
rootView = window.rootView
|
||||
|
||||
afterEach ->
|
||||
window.shutdown()
|
||||
@@ -68,7 +71,7 @@ describe "Window", ->
|
||||
expect(atom.getRootViewStateForPath(window.rootView.project.getPath())).toBeUndefined()
|
||||
expectedState = JSON.parse(JSON.stringify(window.rootView.serialize())) # JSON.stringify removes keys with undefined values
|
||||
$(window).trigger 'beforeunload'
|
||||
expect(atom.getRootViewStateForPath(window.rootView.project.getPath())).toEqual expectedState
|
||||
expect(atom.getRootViewStateForPath(rootView.project.getPath())).toEqual expectedState
|
||||
|
||||
it "unsubscribes from all buffers", ->
|
||||
rootView.open('sample.js')
|
||||
@@ -79,3 +82,12 @@ describe "Window", ->
|
||||
$(window).trigger 'beforeunload'
|
||||
|
||||
expect(editor1.getBuffer().subscriptionCount()).toBe 0
|
||||
|
||||
describe ".shutdown()", ->
|
||||
it "only deactivates the RootView the first time it is called", ->
|
||||
deactivateSpy = spyOn(rootView, "deactivate").andCallThrough()
|
||||
window.shutdown()
|
||||
expect(rootView.deactivate).toHaveBeenCalled()
|
||||
deactivateSpy.reset()
|
||||
window.shutdown()
|
||||
expect(rootView.deactivate).not.toHaveBeenCalled()
|
||||
|
||||
@@ -47,7 +47,8 @@ windowAdditions =
|
||||
false
|
||||
|
||||
shutdown: ->
|
||||
@rootView.deactivate()
|
||||
@rootView?.deactivate()
|
||||
@rootView = null
|
||||
$(window).unbind('focus')
|
||||
$(window).unbind('blur')
|
||||
$(window).off('before')
|
||||
|
||||
Reference in New Issue
Block a user