diff --git a/src/pane-container.coffee b/src/pane-container.coffee index ca768d88a..e0f678765 100644 --- a/src/pane-container.coffee +++ b/src/pane-container.coffee @@ -6,19 +6,18 @@ ItemRegistry = require './item-registry' PaneContainerElement = require './pane-container-element' module.exports = -class PaneContainer extends Model +class PaneContainer serializationVersion: 1 root: null stoppedChangingActivePaneItemDelay: 100 stoppedChangingActivePaneItemTimeout: null constructor: (params) -> - super - {@config, applicationDelegate, notificationManager, deserializerManager, @viewRegistry, @location} = params @emitter = new Emitter @subscriptions = new CompositeDisposable @itemRegistry = new ItemRegistry + @alive = true @setRoot(new Pane({container: this, @config, applicationDelegate, notificationManager, deserializerManager, @viewRegistry})) @setActivePane(@getRoot()) @@ -32,6 +31,17 @@ class PaneContainer extends Model getElement: -> @element ?= new PaneContainerElement().initialize(this, {views: @viewRegistry}) + destroy: -> + @alive = false + @cancelStoppedChangingActivePaneItemTimeout() + pane.destroy() for pane in @getRoot().getPanes() + @subscriptions.dispose() + @emitter.dispose() + + isAlive: -> @alive + + isDestroyed: -> not @isAlive() + serialize: (params) -> deserializer: 'PaneContainer' version: @serializationVersion @@ -206,13 +216,6 @@ class PaneContainer extends Model didDestroyPane: (event) -> @emitter.emit 'did-destroy-pane', event - # Called by Model superclass when destroyed - destroyed: -> - @cancelStoppedChangingActivePaneItemTimeout() - pane.destroy() for pane in @getRoot().getPanes() - @subscriptions.dispose() - @emitter.dispose() - cancelStoppedChangingActivePaneItemTimeout: -> if @stoppedChangingActivePaneItemTimeout? clearTimeout(@stoppedChangingActivePaneItemTimeout)