mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Destroy unretained buffers when serializing project
Previously buffers could linger indefinitely if an error occurred during startup between the deserialization of the project and the original retaining edit session.
This commit is contained in:
@@ -91,9 +91,14 @@ class Project
|
||||
serialize: ->
|
||||
state = @state.clone()
|
||||
state.set('path', @getPath())
|
||||
@destroyUnretainedBuffers()
|
||||
state.set('buffers', buffer.serialize() for buffer in @getBuffers())
|
||||
state
|
||||
|
||||
# Private:
|
||||
destroyUnretainedBuffers: ->
|
||||
buffer.destroy() for buffer in @getBuffers() when not buffer.isRetained()
|
||||
|
||||
# Public: ?
|
||||
getState: -> @state
|
||||
|
||||
|
||||
@@ -81,13 +81,15 @@ class TextBuffer
|
||||
@destroyed = true
|
||||
@project?.removeBuffer(this)
|
||||
|
||||
isRetained: -> @refcount > 0
|
||||
|
||||
retain: ->
|
||||
@refcount++
|
||||
this
|
||||
|
||||
release: ->
|
||||
@refcount--
|
||||
@destroy() if @refcount <= 0
|
||||
@destroy() unless @isRetained()
|
||||
this
|
||||
|
||||
serialize: ->
|
||||
|
||||
Reference in New Issue
Block a user