Make sure window.shutdown is only called once

This commit is contained in:
Corey Johnson & Nathan Sobo 2013-02-20 10:18:19 -08:00
parent 43aa1aaeb7
commit b24a13991a
2 changed files with 9 additions and 0 deletions

View File

@ -109,3 +109,9 @@ describe "Window", ->
shutdown() shutdown()
expect(editor1.getBuffer().subscriptionCount()).toBe 0 expect(editor1.getBuffer().subscriptionCount()).toBe 0
it "only serializes window state the first time it is called", ->
deactivateSpy = spyOn(atom, "setRootViewStateForPath").andCallThrough()
window.shutdown()
window.shutdown()
expect(atom.setRootViewStateForPath.callCount).toBe 1

View File

@ -8,6 +8,7 @@ require 'underscore-extensions'
require 'space-pen-extensions' require 'space-pen-extensions'
deserializers = {} deserializers = {}
wasShutdown = false
windowAdditions = windowAdditions =
rootViewParentSelector: 'body' rootViewParentSelector: 'body'
@ -68,6 +69,8 @@ windowAdditions =
$(rootViewParentSelector).append(rootView) $(rootViewParentSelector).append(rootView)
shutdown: -> shutdown: ->
return if wasShutdown
wasShutdown = true
atom.setWindowState('pathToOpen', project.getPath()) atom.setWindowState('pathToOpen', project.getPath())
atom.setRootViewStateForPath project.getPath(), atom.setRootViewStateForPath project.getPath(),
project: project.serialize() project: project.serialize()