summaryrefslogtreecommitdiff
path: root/libs/pbd/undo.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2006-12-11 12:52:40 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2006-12-11 12:52:40 +0000
commitee0fb82da6a0d511e2aa7e6071ea0fb05cb405e9 (patch)
treeea0a66a9efdf53a6429be2cbf90728f5a63cbc00 /libs/pbd/undo.cc
parent337cee7a8344c76edc9068bf733ee8489b1c9bef (diff)
never save more than Config->get_saved_history_depth() undo transactions to history file
git-svn-id: svn://localhost/ardour2/trunk@1200 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/pbd/undo.cc')
-rw-r--r--libs/pbd/undo.cc26
1 files changed, 22 insertions, 4 deletions
diff --git a/libs/pbd/undo.cc b/libs/pbd/undo.cc
index 277b83bfce..4719d0968e 100644
--- a/libs/pbd/undo.cc
+++ b/libs/pbd/undo.cc
@@ -236,13 +236,31 @@ UndoHistory::clear ()
Changed (); /* EMIT SIGNAL */
}
-XMLNode & UndoHistory::get_state()
+XMLNode&
+UndoHistory::get_state (uint32_t depth)
{
XMLNode *node = new XMLNode ("UndoHistory");
- list<UndoTransaction*>::iterator it;
- for (it = UndoList.begin(); it != UndoList.end(); it++) {
- node->add_child_nocopy((*it)->get_state());
+ 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 */
+
+ list<UndoTransaction*> in_order;
+
+ for (list<UndoTransaction*>::reverse_iterator it = UndoList.rbegin(); it != UndoList.rend() && depth; ++it, depth--) {
+ in_order.push_front (*it);
+ }
+
+ for (list<UndoTransaction*>::iterator it = in_order.begin(); it != in_order.end(); it++) {
+ node->add_child_nocopy((*it)->get_state());
+ }
}
return *node;