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
This commit is contained in:
Hans Fugal 2006-08-10 01:45:49 +00:00
parent cd3f8dba11
commit 74b19eadfa
5 changed files with 38 additions and 9 deletions

View File

@ -1,3 +1,3 @@
#!/bin/sh
source ardev_common.sh
exec gdb ./ardour.bin
exec gdb ./ardour.bin "$*"

View 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;
}

View 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;

View 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)

View 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: