diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 08c716d442..0b9359bae7 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -2970,8 +2970,8 @@ void Editor::begin_reversible_command (string name) { if (session) { - UndoAction ua = get_memento(); - session->begin_reversible_command (name, &ua); + before = get_state(); + session->begin_reversible_command (name); } } @@ -2979,8 +2979,12 @@ void Editor::commit_reversible_command () { if (session) { - UndoAction ua = get_memento(); - session->commit_reversible_command (&ua); + // yes, cmd lasts long enough to be copied onto the action + // list in the history, but this has the potential to be a + // problem if memory management of actions changes in + // UndoTransaction + MementoCommand cmd(*this, before, get_state()); + session->commit_reversible_command (&cmd); } } diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index e517b1eaf1..2ef475a5e4 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -1608,6 +1608,7 @@ class Editor : public PublicEditor UndoAction get_memento() const; + XMLNode &before; /* used in *_reversible_command */ void begin_reversible_command (string cmd_name); void commit_reversible_command (); diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 971e141363..ba12b79f48 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -841,8 +841,8 @@ class Session : public sigc::trackable, public Stateful string next_undo() const { return history.next_undo(); } string next_redo() const { return history.next_redo(); } - void begin_reversible_command (string cmd_name, UndoAction *private_undo = 0); - void commit_reversible_command (UndoAction* private_redo = 0); + void begin_reversible_command (string cmd_name); + void commit_reversible_command (Command* cmd = 0); void add_undo (const UndoAction& ua) { current_trans.add_undo (ua); diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 92a21ea794..deda3363ab 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -2564,23 +2564,19 @@ Session::set_meter_falloff (float val) void -Session::begin_reversible_command (string name, UndoAction* private_undo) +Session::begin_reversible_command (string name) { current_trans.clear (); current_trans.set_name (name); - - if (private_undo) { - current_trans.add_undo (*private_undo); - } } void -Session::commit_reversible_command (UndoAction* private_redo) +Session::commit_reversible_command (Command *cmd) { struct timeval now; - if (private_redo) { - current_trans.add_redo_no_execute (*private_redo); + if (cmd) { + current_trans.add_command (*cmd); } gettimeofday (&now, 0);