diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2007-10-11 22:07:47 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2007-10-11 22:07:47 +0000 |
commit | f7f9d6fdc40248b190ec9c6e1a886261d55777ae (patch) | |
tree | 080723e9dc35a66013b37acbafc67a6afa929302 /libs/pbd/undo.cc | |
parent | aa1f736a651376534acaa2268b65d42a3786fff7 (diff) |
merge from 2.0-ongoing by hand, minus key binding editor
git-svn-id: svn://localhost/ardour2/trunk@2539 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/pbd/undo.cc')
-rw-r--r-- | libs/pbd/undo.cc | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/libs/pbd/undo.cc b/libs/pbd/undo.cc index 6db85e6ab3..aeff37cce7 100644 --- a/libs/pbd/undo.cc +++ b/libs/pbd/undo.cc @@ -148,12 +148,28 @@ XMLNode &UndoTransaction::get_state() UndoHistory::UndoHistory () { _clearing = false; + _depth = 0; +} + +void +UndoHistory::set_depth (int32_t d) +{ + _depth = d; + + while (_depth > 0 && UndoList.size() > (uint32_t) _depth) { + UndoList.pop_front (); + } } void UndoHistory::add (UndoTransaction* const ut) { ut->GoingAway.connect (bind (mem_fun (*this, &UndoHistory::remove), ut)); + + while (_depth > 0 && UndoList.size() > (uint32_t) _depth) { + UndoList.pop_front (); + } + UndoList.push_back (ut); /* we are now owners of the transaction */ @@ -240,17 +256,22 @@ UndoHistory::clear () } XMLNode& -UndoHistory::get_state (uint32_t depth) +UndoHistory::get_state (int32_t depth) { XMLNode *node = new XMLNode ("UndoHistory"); if (depth == 0) { + + return (*node); + + } else if (depth < 0) { + /* everything */ for (list<UndoTransaction*>::iterator it = UndoList.begin(); it != UndoList.end(); ++it) { node->add_child_nocopy((*it)->get_state()); } - + } else { /* just the last "depth" transactions */ @@ -268,3 +289,5 @@ UndoHistory::get_state (uint32_t depth) return *node; } + + |