Serialize package states independently of RootView

Previously, package specs needed to deactivate the root view to test
their package serialization. Now, specs can just deactivate and then
reactivate the package, relying on serialization infrastructure that's
independent of the lifecycle of the RootView.
This commit is contained in:
Nathan Sobo
2013-03-25 15:37:11 -06:00
parent f5774972e9
commit bb8b3782b9
12 changed files with 35 additions and 49 deletions

View File

@@ -27,11 +27,6 @@ _.extend atom,
setPackageState: (name, state) ->
@packageStates[name] = state
serializeAtomPackages: ->
for pack in @getActivePackages()
@setPackageState(pack.name, state) if state = pack.serialize?()
@packageStates
activatePackages: ->
@activatePackage(pack.path) for pack in @getLoadedPackages()

View File

@@ -29,8 +29,7 @@ class RootView extends View
@div id: 'vertical', outlet: 'vertical', =>
@subview 'panes', panes ? new PaneContainer
@deserialize: ({ panes, packages, projectPath }) ->
atom.packageStates = packages ? {}
@deserialize: ({ panes }) ->
panes = deserialize(panes) if panes?.deserializer is 'PaneContainer'
new RootView({panes})
@@ -73,7 +72,6 @@ class RootView extends View
version: RootView.version
deserializer: 'RootView'
panes: @panes.serialize()
packages: atom.serializeAtomPackages()
confirmClose: ->
@panes.confirmClose()
@@ -94,10 +92,6 @@ class RootView extends View
afterAttach: (onDom) ->
@focus() if onDom
deactivate: ->
atom.deactivatePackages()
@remove()
open: (path, options = {}) ->
changeFocus = options.changeFocus ? true
path = project.resolve(path) if path?

View File

@@ -61,10 +61,12 @@ window.shutdown = ->
return if not project and not rootView
atom.setWindowState('pathToOpen', project.getPath())
atom.setWindowState('project', project.serialize())
atom.setWindowState('rootView', rootView.serialize())
atom.setWindowState('syntax', syntax.serialize())
atom.setWindowState('rootView', rootView.serialize())
atom.deactivatePackages()
atom.setWindowState('packageStates', atom.packageStates)
rootView.remove()
atom.saveWindowState()
rootView.deactivate()
project.destroy()
git?.destroy()
$(window).off('focus blur before')
@@ -95,6 +97,7 @@ window.deserializeWindowState = ->
windowState = atom.getWindowState()
atom.packageStates = windowState.packageStates ? {}
window.project = deserialize(windowState.project) ? new Project(pathToOpen)
window.rootView = deserialize(windowState.rootView) ? new RootView