r184@gandalf: fugalh | 2006-07-17 19:02:10 -0600

(begin|commit)_reversible_command in Editor and Session


git-svn-id: svn://localhost/ardour2/branches/undo@684 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Hans Fugal 2006-07-18 17:47:12 +00:00
parent 72168803ee
commit d819b922e1
4 changed files with 15 additions and 14 deletions

View file

@ -2970,8 +2970,8 @@ void
Editor::begin_reversible_command (string name) Editor::begin_reversible_command (string name)
{ {
if (session) { if (session) {
UndoAction ua = get_memento(); before = get_state();
session->begin_reversible_command (name, &ua); session->begin_reversible_command (name);
} }
} }
@ -2979,8 +2979,12 @@ void
Editor::commit_reversible_command () Editor::commit_reversible_command ()
{ {
if (session) { if (session) {
UndoAction ua = get_memento(); // yes, cmd lasts long enough to be copied onto the action
session->commit_reversible_command (&ua); // list in the history, but this has the potential to be a
// problem if memory management of actions changes in
// UndoTransaction
MementoCommand<Editor> cmd(*this, before, get_state());
session->commit_reversible_command (&cmd);
} }
} }

View file

@ -1608,6 +1608,7 @@ class Editor : public PublicEditor
UndoAction get_memento() const; UndoAction get_memento() const;
XMLNode &before; /* used in *_reversible_command */
void begin_reversible_command (string cmd_name); void begin_reversible_command (string cmd_name);
void commit_reversible_command (); void commit_reversible_command ();

View file

@ -841,8 +841,8 @@ class Session : public sigc::trackable, public Stateful
string next_undo() const { return history.next_undo(); } string next_undo() const { return history.next_undo(); }
string next_redo() const { return history.next_redo(); } string next_redo() const { return history.next_redo(); }
void begin_reversible_command (string cmd_name, UndoAction *private_undo = 0); void begin_reversible_command (string cmd_name);
void commit_reversible_command (UndoAction* private_redo = 0); void commit_reversible_command (Command* cmd = 0);
void add_undo (const UndoAction& ua) { void add_undo (const UndoAction& ua) {
current_trans.add_undo (ua); current_trans.add_undo (ua);

View file

@ -2564,23 +2564,19 @@ Session::set_meter_falloff (float val)
void void
Session::begin_reversible_command (string name, UndoAction* private_undo) Session::begin_reversible_command (string name)
{ {
current_trans.clear (); current_trans.clear ();
current_trans.set_name (name); current_trans.set_name (name);
if (private_undo) {
current_trans.add_undo (*private_undo);
}
} }
void void
Session::commit_reversible_command (UndoAction* private_redo) Session::commit_reversible_command (Command *cmd)
{ {
struct timeval now; struct timeval now;
if (private_redo) { if (cmd) {
current_trans.add_redo_no_execute (*private_redo); current_trans.add_command (*cmd);
} }
gettimeofday (&now, 0); gettimeofday (&now, 0);