diff options
author | Hans Fugal <hans@fugal.net> | 2006-07-18 17:47:12 +0000 |
---|---|---|
committer | Hans Fugal <hans@fugal.net> | 2006-07-18 17:47:12 +0000 |
commit | d819b922e1d858dc3addbe31962d12af64027e50 (patch) | |
tree | 45aeb253f0fcbb2314c1eb058670a2448d706943 | |
parent | 72168803ee845adef9743fd24421b9719a0901b0 (diff) |
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
-rw-r--r-- | gtk2_ardour/editor.cc | 12 | ||||
-rw-r--r-- | gtk2_ardour/editor.h | 1 | ||||
-rw-r--r-- | libs/ardour/ardour/session.h | 4 | ||||
-rw-r--r-- | libs/ardour/session_state.cc | 12 |
4 files changed, 15 insertions, 14 deletions
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<Editor> 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); |