summaryrefslogtreecommitdiff
path: root/libs
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
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')
-rw-r--r--libs/ardour/ardour/configuration_vars.h1
-rw-r--r--libs/ardour/session_state.cc17
-rw-r--r--libs/pbd/pbd/undo.h2
-rw-r--r--libs/pbd/undo.cc26
4 files changed, 35 insertions, 11 deletions
diff --git a/libs/ardour/ardour/configuration_vars.h b/libs/ardour/ardour/configuration_vars.h
index f54fe15b71..89857ac9f5 100644
--- a/libs/ardour/ardour/configuration_vars.h
+++ b/libs/ardour/ardour/configuration_vars.h
@@ -120,6 +120,7 @@ CONFIG_VARIABLE (bool, verify_remove_last_capture, "verify-remove-last-capture",
CONFIG_VARIABLE (bool, no_new_session_dialog, "no-new-session-dialog", false)
CONFIG_VARIABLE (bool, use_vst, "use-vst", true)
CONFIG_VARIABLE (uint32_t, subframes_per_frame, "subframes-per-frame", 100)
+CONFIG_VARIABLE (uint32_t, saved_history_depth, "save-history-depth", 100)
/* BWAV */
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc
index 0d54e2535e..e97d2b6831 100644
--- a/libs/ardour/session_state.cc
+++ b/libs/ardour/session_state.cc
@@ -2796,8 +2796,13 @@ Session::save_history (string snapshot_name)
XMLTree tree;
string xml_path;
string bak_path;
-
- tree.set_root (&_history.get_state());
+ XMLNode& history_node (history.get_state (Config->get_saved_history_depth()));
+
+ if (history_node.children().empty()) {
+ return 0;
+ }
+
+ tree.set_root (
if (snapshot_name.empty()) {
snapshot_name = _current_snapshot_name;
@@ -2850,13 +2855,13 @@ Session::restore_history (string snapshot_name)
cerr << string_compose(_("Loading history from '%1'."), xmlpath) << endmsg;
if (access (xmlpath.c_str(), F_OK)) {
- error << string_compose(_("%1: session history file \"%2\" doesn't exist!"), _name, xmlpath) << endmsg;
- return 1;
+ info << string_compose (_("%1: no history file \"%2\" for this session."), _name, xmlpath) << endmsg;
+ return 1;
}
if (!tree.read (xmlpath)) {
- error << string_compose(_("Could not understand ardour file %1"), xmlpath) << endmsg;
- return -1;
+ error << string_compose (_("Could not understand session history file \"%1\""), xmlpath) << endmsg;
+ return -1;
}
/* replace history */
diff --git a/libs/pbd/pbd/undo.h b/libs/pbd/pbd/undo.h
index eb46750e4f..4dfab5178f 100644
--- a/libs/pbd/pbd/undo.h
+++ b/libs/pbd/pbd/undo.h
@@ -94,7 +94,7 @@ class UndoHistory : public sigc::trackable
void clear_undo ();
void clear_redo ();
- XMLNode &get_state();
+ XMLNode &get_state(uint32_t depth = 0);
void save_state();
sigc::signal<void> Changed;
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;