Can pass a core to ardbg now. Fixed sometimes crash on saving history by
authorHans Fugal <hans@fugal.net>
Thu, 10 Aug 2006 01:45:49 +0000 (01:45 +0000)
committerHans Fugal <hans@fugal.net>
Thu, 10 Aug 2006 01:45:49 +0000 (01:45 +0000)
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
gtk2_ardour/automation_line.cc
libs/ardour/ardour/session.h
libs/ardour/session_command.cc
libs/pbd/pbd/memento_command.h

index 267fdbae737a1228b17c20332a590498958c9a2b..9d3f5bf6c75ae4d21ee0097490f4cff4044afebb 100755 (executable)
@@ -1,3 +1,3 @@
 #!/bin/sh
 source ardev_common.sh
-exec gdb ./ardour.bin
+exec gdb ./ardour.bin "$*"
index 5c09ddd49b35e1c90d9d8e7f3dcfe07a81ef2394..f3e30c4523428f6292d91a209863f11c18e5c4ad 100644 (file)
@@ -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;
 }
index 69ba373456596b96b9851d10e15221e016af4284..632e85eade05272c737557a0d267188047e107a9 100644 (file)
@@ -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;
index 9a43de55de17ee1f9c8a04ce5984a96e3ae539d8..276b2c182289a9213e255237f0980d9f54cdb2a6 100644 (file)
@@ -1,7 +1,28 @@
 #include <ardour/session.h>
 #include <ardour/route.h>
+#include <pbd/memento_command.h>
+#include <ardour/diskstream.h>
 
 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<Diskstream>(*obj, *before, *after);
+    // etc.
+}
+
 // solo
 Session::GlobalSoloStateCommand::GlobalSoloStateCommand(Session &sess, void *src)
     : sess(sess), src(src)
index 46c724e9ea61be335ac5a2790b84a11356783a0d..122dcb4c860ed0972c7fd2377a0c7daba2ba48e6 100644 (file)
@@ -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: