From 74b19eadfab8e57df2cb4270382efb453709dadd Mon Sep 17 00:00:00 2001 From: Hans Fugal Date: Thu, 10 Aug 2006 01:45:49 +0000 Subject: [PATCH] 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 --- gtk2_ardour/ardbg | 2 +- gtk2_ardour/automation_line.cc | 7 ++++--- libs/ardour/ardour/session.h | 1 + libs/ardour/session_command.cc | 21 +++++++++++++++++++++ libs/pbd/pbd/memento_command.h | 16 +++++++++++----- 5 files changed, 38 insertions(+), 9 deletions(-) diff --git a/gtk2_ardour/ardbg b/gtk2_ardour/ardbg index 267fdbae73..9d3f5bf6c7 100755 --- a/gtk2_ardour/ardbg +++ b/gtk2_ardour/ardbg @@ -1,3 +1,3 @@ #!/bin/sh source ardev_common.sh -exec gdb ./ardour.bin +exec gdb ./ardour.bin "$*" diff --git a/gtk2_ardour/automation_line.cc b/gtk2_ardour/automation_line.cc index 5c09ddd49b..f3e30c4523 100644 --- a/gtk2_ardour/automation_line.cc +++ b/gtk2_ardour/automation_line.cc @@ -1270,13 +1270,14 @@ AutomationLine::hide_all_but_selected_control_points () XMLNode &AutomationLine::get_state(void) { - // TODO - return alist.get_state(); + XMLNode *node = new XMLNode("AutomationLine"); + node->add_child_nocopy(alist.get_state()); + return *node; } int AutomationLine::set_state(const XMLNode &node) { // TODO - alist.set_state(node); + //alist.set_state(node); return 0; } diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 69ba373456..632e85eade 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -839,6 +839,7 @@ class Session : public sigc::trackable, public Stateful } // these commands are implemented in libs/ardour/session_command.cc + Command *memento_command_factory(XMLNode *n); class GlobalSoloStateCommand : public Command { GlobalRouteBooleanState before, after; diff --git a/libs/ardour/session_command.cc b/libs/ardour/session_command.cc index 9a43de55de..276b2c1822 100644 --- a/libs/ardour/session_command.cc +++ b/libs/ardour/session_command.cc @@ -1,7 +1,28 @@ #include #include +#include +#include namespace ARDOUR { + +Command *Session::memento_command_factory(XMLNode *n) +{ + PBD::ID id; + XMLNode *before, *after; + void *obj; + + /* get obj_id */ + + /* get before and/or after */ + + /* get an object by id by trial and error, and use it to construct an + * appropriate memento command */ + // e.g. + if (Diskstream *obj = diskstream_by_id(id)) + return new MementoCommand(*obj, *before, *after); + // etc. +} + // solo Session::GlobalSoloStateCommand::GlobalSoloStateCommand(Session &sess, void *src) : sess(sess), src(src) 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 #include #include +#include /** 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 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 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 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: