From b24a13991aebbd41167bb1bd5ca6a5cc3bfdab46 Mon Sep 17 00:00:00 2001 From: Corey Johnson & Nathan Sobo Date: Wed, 20 Feb 2013 10:18:19 -0800 Subject: [PATCH] Make sure window.shutdown is only called once --- spec/app/window-spec.coffee | 6 ++++++ src/app/window.coffee | 3 +++ 2 files changed, 9 insertions(+) diff --git a/spec/app/window-spec.coffee b/spec/app/window-spec.coffee index 825eefb4c..ff82cc5fa 100644 --- a/spec/app/window-spec.coffee +++ b/spec/app/window-spec.coffee @@ -109,3 +109,9 @@ describe "Window", -> shutdown() 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 diff --git a/src/app/window.coffee b/src/app/window.coffee index 59135f8e2..b181d4f0a 100644 --- a/src/app/window.coffee +++ b/src/app/window.coffee @@ -8,6 +8,7 @@ require 'underscore-extensions' require 'space-pen-extensions' deserializers = {} +wasShutdown = false windowAdditions = rootViewParentSelector: 'body' @@ -68,6 +69,8 @@ windowAdditions = $(rootViewParentSelector).append(rootView) shutdown: -> + return if wasShutdown + wasShutdown = true atom.setWindowState('pathToOpen', project.getPath()) atom.setRootViewStateForPath project.getPath(), project: project.serialize()