mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-08 06:35:46 +01:00
Support recursive undo events.
Code can now call begin_reversible_command and commit_reversible_command around a region of code which itself calls those functions (and so on), areas contained within enclosing regions will be added as sub-commands of the current command (i.e. it's a stack). Fixes mantix issue #0002558. git-svn-id: svn://localhost/ardour2/branches/3.0@5051 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
90c82a97a7
commit
83c27fa888
5 changed files with 32 additions and 25 deletions
|
|
@ -838,7 +838,8 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
|
|||
void commit_reversible_command (Command* cmd = 0);
|
||||
|
||||
void add_command (Command *const cmd) {
|
||||
current_trans->add_command (cmd);
|
||||
assert(!_current_trans.empty ());
|
||||
_current_trans.top()->add_command (cmd);
|
||||
}
|
||||
|
||||
std::map<PBD::ID, PBD::StatefulThingWithGoingAway*> registry;
|
||||
|
|
@ -1613,8 +1614,8 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
|
|||
|
||||
void reverse_diskstream_buffers ();
|
||||
|
||||
UndoHistory _history;
|
||||
UndoTransaction* current_trans;
|
||||
UndoHistory _history;
|
||||
std::stack<UndoTransaction*> _current_trans;
|
||||
|
||||
GlobalRouteBooleanState get_global_route_boolean (bool (Route::*method)(void) const);
|
||||
GlobalRouteMeterState get_global_route_metering ();
|
||||
|
|
|
|||
|
|
@ -205,7 +205,6 @@ Session::first_stage_init (string fullpath, string snapshot_name)
|
|||
_npan_buffers = 0;
|
||||
pending_abort = false;
|
||||
destructive_index = 0;
|
||||
current_trans = 0;
|
||||
first_file_data_format_reset = true;
|
||||
first_file_header_format_reset = true;
|
||||
butler_thread = (pthread_t) 0;
|
||||
|
|
@ -2251,29 +2250,36 @@ Session::edit_group_by_name (string name)
|
|||
}
|
||||
|
||||
void
|
||||
Session::begin_reversible_command (const string& name)
|
||||
Session::begin_reversible_command(const string& name)
|
||||
{
|
||||
current_trans = new UndoTransaction;
|
||||
current_trans->set_name (name);
|
||||
UndoTransaction* trans = new UndoTransaction();
|
||||
trans->set_name(name);
|
||||
if (!_current_trans.empty()) {
|
||||
_current_trans.top()->add_command(trans);
|
||||
}
|
||||
_current_trans.push(trans);
|
||||
}
|
||||
|
||||
void
|
||||
Session::commit_reversible_command (Command *cmd)
|
||||
Session::commit_reversible_command(Command *cmd)
|
||||
{
|
||||
assert(!_current_trans.empty());
|
||||
struct timeval now;
|
||||
|
||||
if (cmd) {
|
||||
current_trans->add_command (cmd);
|
||||
_current_trans.top()->add_command(cmd);
|
||||
}
|
||||
|
||||
if (current_trans->empty()) {
|
||||
if (_current_trans.top()->empty()) {
|
||||
_current_trans.pop();
|
||||
return;
|
||||
}
|
||||
|
||||
gettimeofday (&now, 0);
|
||||
current_trans->set_timestamp (now);
|
||||
gettimeofday(&now, 0);
|
||||
_current_trans.top()->set_timestamp(now);
|
||||
|
||||
_history.add (current_trans);
|
||||
_history.add(_current_trans.top());
|
||||
_current_trans.pop();
|
||||
}
|
||||
|
||||
Session::GlobalRouteBooleanState
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue