From 116c56c236c261e691c9bcf753cf35f903680772 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki & Nathan Sobo Date: Tue, 20 Aug 2013 18:29:19 -0700 Subject: [PATCH] Serialize site across window loads This prevents issues with the site counter resetting to 1 on each load causing duplicate array and marker ids to be generated. Closes #729 --- src/atom.coffee | 14 +++++++++++--- src/window.coffee | 1 - vendor/telepath | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/atom.coffee b/src/atom.coffee index 6a795efe2..5c6073d78 100644 --- a/src/atom.coffee +++ b/src/atom.coffee @@ -228,11 +228,19 @@ window.atom = catch error console.warn "Error parsing window state: #{windowStatePath}", error.stack, error - windowState ?= {} - site.deserializeDocument(windowState) ? site.createDocument({}) + {site, document} = windowState ? {} + if site? and document? + window.site = telepath.Site.deserialize(site) + window.site.deserializeDocument(document) + else + window.site = new telepath.Site(1) + window.site.createDocument({}) saveWindowState: -> - windowStateJson = JSON.stringify(@getWindowState().serialize(), null, 2) + windowState = + site: site.serialize() + document: @getWindowState().serialize() + windowStateJson = JSON.stringify(windowState, null, 2) if windowStatePath = @getWindowStatePath() fsUtils.writeSync(windowStatePath, "#{windowStateJson}\n") else diff --git a/src/window.coffee b/src/window.coffee index ebc5c95bc..d5b693f96 100644 --- a/src/window.coffee +++ b/src/window.coffee @@ -21,7 +21,6 @@ windowEventHandler = null # This method is called in any window needing a general environment, including specs window.setUpEnvironment = (windowMode) -> - window.site = new telepath.Site(1) atom.windowMode = windowMode window.resourcePath = remote.getCurrentWindow().loadSettings.resourcePath diff --git a/vendor/telepath b/vendor/telepath index 064b0df33..2638740aa 160000 --- a/vendor/telepath +++ b/vendor/telepath @@ -1 +1 @@ -Subproject commit 064b0df33a9dc501d9355c69cecdb119ad1fd6cc +Subproject commit 2638740aa0686440046cb0b9650df5b236451a53