summaryrefslogtreecommitdiff
path: root/libs/pbd/stateful_diff_command.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2010-06-23 20:14:07 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2010-06-23 20:14:07 +0000
commitf4401c59284258c6aa56707da64e3da32756329f (patch)
tree73679199ae43516347d607adad212c10612f7eb9 /libs/pbd/stateful_diff_command.cc
parentcac03dbeb6ebdcd406385dd14a746cb8c51dd5f8 (diff)
midway snapshot of work done on managing Region & Source lifetimes correctly. may fix missing MIDI file bug ; save empty playlists because they may be referred to by the history file ; undo commands auto-delete when objects they refer to die (currently not commands built from XML deserialization); Sources now know how many regions are using them for something, meaning that we know if we can delete the files holding any data for the source
git-svn-id: svn://localhost/ardour2/branches/3.0@7291 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/pbd/stateful_diff_command.cc')
-rw-r--r--libs/pbd/stateful_diff_command.cc22
1 files changed, 18 insertions, 4 deletions
diff --git a/libs/pbd/stateful_diff_command.cc b/libs/pbd/stateful_diff_command.cc
index 635fe4829a..2c58acee14 100644
--- a/libs/pbd/stateful_diff_command.cc
+++ b/libs/pbd/stateful_diff_command.cc
@@ -32,15 +32,21 @@ using namespace PBD;
* @param s Stateful object.
*/
-StatefulDiffCommand::StatefulDiffCommand (boost::shared_ptr<Stateful> s)
- : _object (s)
+StatefulDiffCommand::StatefulDiffCommand (boost::shared_ptr<StatefulDestructible> s)
+ : _object (s)
, _undo (new PropertyList)
, _redo (new PropertyList)
{
- s->diff (*_undo, *_redo);
+ s->diff (*_undo, *_redo, this);
+
+ /* if the stateful object that this command refers to goes away,
+ be sure to notify owners of this command.
+ */
+
+ s->DropReferences.connect_same_thread (*this, boost::bind (&Destructible::drop_references, this));
}
-StatefulDiffCommand::StatefulDiffCommand (boost::shared_ptr<Stateful> s, XMLNode const & n)
+StatefulDiffCommand::StatefulDiffCommand (boost::shared_ptr<StatefulDestructible> s, XMLNode const & n)
: _object (s)
, _undo (0)
, _redo (0)
@@ -57,10 +63,18 @@ StatefulDiffCommand::StatefulDiffCommand (boost::shared_ptr<Stateful> s, XMLNode
assert (_undo != 0);
assert (_redo != 0);
+
+ /* if the stateful object that this command refers to goes away,
+ be sure to notify owners of this command.
+ */
+
+ s->DropReferences.connect_same_thread (*this, boost::bind (&Destructible::drop_references, this));
}
StatefulDiffCommand::~StatefulDiffCommand ()
{
+ drop_references ();
+
delete _undo;
delete _redo;
}