diff options
author | Carl Hetherington <carl@carlh.net> | 2011-01-19 17:38:56 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2011-01-19 17:38:56 +0000 |
commit | 1e8586742e48f56bb81fa14c50442cec23894dfd (patch) | |
tree | 717797af5e3e87e67a1356e14a5d74520cbbd904 /libs/ardour/session_state.cc | |
parent | 074d58fc6f97c225e804d32b5d2b8f09e4d512da (diff) |
Fix session range location by hooking into the undo system. Fixes #3654.
git-svn-id: svn://localhost/ardour2/branches/3.0@8539 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/session_state.cc')
-rw-r--r-- | libs/ardour/session_state.cc | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index e7ccb02c7b..4f11291637 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -2364,6 +2364,16 @@ Session::add_commands (vector<Command*> const & cmds) void Session::begin_reversible_command (const string& name) { + begin_reversible_command (g_quark_from_string (name.c_str ())); +} + +/** Begin a reversible command using a GQuark to identify it. + * begin_reversible_command() and commit_reversible_command() calls may be nested, + * but there must be as many begin...()s as there are commit...()s. + */ +void +Session::begin_reversible_command (GQuark q) +{ /* If nested begin/commit pairs are used, we create just one UndoTransaction to hold all the commands that are committed. This keeps the order of commands correct in the history. @@ -2371,20 +2381,19 @@ Session::begin_reversible_command (const string& name) if (_current_trans == 0) { /* start a new transaction */ - assert (_current_trans_depth == 0); + assert (_current_trans_quarks.empty ()); _current_trans = new UndoTransaction(); - _current_trans->set_name (name); - } else { - /* use the existing transaction */ - ++_current_trans_depth; + _current_trans->set_name (g_quark_to_string (q)); } + + _current_trans_quarks.push_front (q); } void Session::commit_reversible_command (Command *cmd) { assert (_current_trans); - assert (_current_trans_depth > 0); + assert (!_current_trans_quarks.empty ()); struct timeval now; @@ -2392,9 +2401,9 @@ Session::commit_reversible_command (Command *cmd) _current_trans->add_command (cmd); } - --_current_trans_depth; + _current_trans_quarks.pop_front (); - if (_current_trans_depth > 0) { + if (!_current_trans_quarks.empty ()) { /* the transaction we're committing is not the top-level one */ return; } |