diff options
author | Hans Fugal <hans@fugal.net> | 2006-08-10 01:45:49 +0000 |
---|---|---|
committer | Hans Fugal <hans@fugal.net> | 2006-08-10 01:45:49 +0000 |
commit | 74b19eadfab8e57df2cb4270382efb453709dadd (patch) | |
tree | 441cf4a217541c200962e55f584113c4e6681efc /libs/pbd | |
parent | cd3f8dba11065da6933b8f361623612fa6be4145 (diff) |
Can pass a core to ardbg now. Fixed sometimes crash on saving history by
creating a memory leak(?) that will go away with the transition of XMLNode* to
shared_ptr<>. A few bits toward restoring history from XML.
git-svn-id: svn://localhost/ardour2/branches/undo@779 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/pbd')
-rw-r--r-- | libs/pbd/pbd/memento_command.h | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/libs/pbd/pbd/memento_command.h b/libs/pbd/pbd/memento_command.h index 46c724e9ea..122dcb4c86 100644 --- a/libs/pbd/pbd/memento_command.h +++ b/libs/pbd/pbd/memento_command.h @@ -24,6 +24,7 @@ #include <pbd/command.h> #include <pbd/xml++.h> #include <sigc++/slot.h> +#include <typeinfo> /** This command class is initialized with before and after mementos * (from Stateful::get_state()), so undo becomes restoring the before @@ -33,6 +34,7 @@ template <class obj_T> class MementoCommand : public Command { public: + MementoCommand(XMLNode &state); MementoCommand(obj_T &obj, XMLNode &before, XMLNode &after @@ -44,11 +46,11 @@ class MementoCommand : public Command { XMLNode *node = new XMLNode("MementoCommand"); node->add_property("obj_id", obj.id().to_s()); - node->add_child_nocopy(before); - node->add_child_nocopy(after); + node->add_property("type_name", typeid(obj).name()); + node->add_child_copy(before); + node->add_child_copy(after); return *node; } - // TODO does this need a copy constructor? protected: obj_T &obj; XMLNode &before, &after; @@ -58,6 +60,7 @@ template <class obj_T> class MementoUndoCommand : public Command { public: + MementoUndoCommand(XMLNode &state); MementoUndoCommand(obj_T &obj, XMLNode &before) : obj(obj), before(before) {} @@ -67,7 +70,8 @@ public: { XMLNode *node = new XMLNode("MementoUndoCommand"); node->add_property("obj_id", obj.id().to_s()); - node->add_child_nocopy(before); + node->add_property("type_name", typeid(obj).name()); + node->add_child_copy(before); return *node; } protected: @@ -79,6 +83,7 @@ template <class obj_T> class MementoRedoCommand : public Command { public: + MementoRedoCommand(XMLNode &state); MementoRedoCommand(obj_T &obj, XMLNode &after) : obj(obj), after(after) {} @@ -88,7 +93,8 @@ public: { XMLNode *node = new XMLNode("MementoRedoCommand"); node->add_property("obj_id", obj.id().to_s()); - node->add_child_nocopy(after); + node->add_property("type_name", typeid(obj).name()); + node->add_child_copy(after); return *node; } protected: |