From f7f9d6fdc40248b190ec9c6e1a886261d55777ae Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Oct 2007 22:07:47 +0000 Subject: merge from 2.0-ongoing by hand, minus key binding editor git-svn-id: svn://localhost/ardour2/trunk@2539 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/pbd/undo.cc | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'libs/pbd/undo.cc') 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::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; } + + -- cgit v1.2.3