diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2007-09-26 14:36:49 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2007-09-26 14:36:49 +0000 |
commit | af895ef50d80bae4f5bb63ee563604804eeb2fb2 (patch) | |
tree | 1ee2e2f0529d95283db11a89cb8f721c0a458e6c /libs | |
parent | 555cbaf613f1aca0654ca173dce4162ef7e122f3 (diff) |
GUI control over saved and in-memory history depth
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@2486 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/ardour/configuration_vars.h | 5 | ||||
-rw-r--r-- | libs/ardour/session_state.cc | 15 | ||||
-rw-r--r-- | libs/pbd/pbd/undo.h | 8 | ||||
-rw-r--r-- | libs/pbd/undo.cc | 15 |
4 files changed, 25 insertions, 18 deletions
diff --git a/libs/ardour/ardour/configuration_vars.h b/libs/ardour/ardour/configuration_vars.h index 4bbfe89bdc..8473f0f4d0 100644 --- a/libs/ardour/ardour/configuration_vars.h +++ b/libs/ardour/ardour/configuration_vars.h @@ -138,8 +138,9 @@ 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", 20) -CONFIG_VARIABLE (uint32_t, history_depth, "history-depth", 20) +CONFIG_VARIABLE (bool, save_history, "save-history", true) +CONFIG_VARIABLE (int32_t, saved_history_depth, "save-history-depth", 20) +CONFIG_VARIABLE (int32_t, history_depth, "history-depth", 20) CONFIG_VARIABLE (bool, use_overlap_equivalency, "use-overlap-equivalency", false) CONFIG_VARIABLE (bool, periodic_safety_backups, "periodic-safety-backups", true) CONFIG_VARIABLE (uint32_t, periodic_safety_backup_interval, "periodic-safety-backup-interval", 120) diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 8067ae581b..f704bbad5f 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -2989,8 +2989,6 @@ Session::save_history (string snapshot_name) string xml_path; string bak_path; - tree.set_root (&_history.get_state (Config->get_saved_history_depth())); - if (snapshot_name.empty()) { snapshot_name = _current_snapshot_name; } @@ -2999,13 +2997,17 @@ Session::save_history (string snapshot_name) bak_path = xml_path + ".bak"; - if ((access (xml_path.c_str(), F_OK) == 0) && - (rename (xml_path.c_str(), bak_path.c_str()))) - { + if (Glib::file_test (xml_path, Glib::FILE_TEST_EXISTS) && ::rename (xml_path.c_str(), bak_path.c_str())) { error << _("could not backup old history file, current history not saved.") << endmsg; return -1; } + if (!Config->get_save_history() || Config->get_saved_history_depth() < 0) { + return 0; + } + + tree.set_root (&_history.get_state (Config->get_saved_history_depth())); + if (!tree.write (xml_path)) { error << string_compose (_("history could not be saved to %1"), xml_path) << endmsg; @@ -3043,8 +3045,7 @@ Session::restore_history (string snapshot_name) xmlpath = _path + snapshot_name + ".history"; cerr << string_compose(_("Loading history from '%1'."), xmlpath) << endmsg; - if (access (xmlpath.c_str(), F_OK)) { - info << string_compose (_("%1: no history file \"%2\" for this session."), _name, xmlpath) << endmsg; + if (!Glib::file_test (xmlpath, Glib::FILE_TEST_EXISTS)) { return 1; } diff --git a/libs/pbd/pbd/undo.h b/libs/pbd/pbd/undo.h index 3f4a1c5e9d..fa53648b24 100644 --- a/libs/pbd/pbd/undo.h +++ b/libs/pbd/pbd/undo.h @@ -93,17 +93,17 @@ class UndoHistory : public sigc::trackable void clear_undo (); void clear_redo (); - XMLNode &get_state(uint32_t depth = 0); + XMLNode &get_state(int32_t depth = 0); void save_state(); - void set_depth (uint32_t); - uint32_t get_depth() const { return _depth; } + void set_depth (int32_t); + int32_t get_depth() const { return _depth; } sigc::signal<void> Changed; private: bool _clearing; - uint32_t _depth; + int32_t _depth; std::list<UndoTransaction*> UndoList; std::list<UndoTransaction*> RedoList; diff --git a/libs/pbd/undo.cc b/libs/pbd/undo.cc index d54c6b0fff..f59228082d 100644 --- a/libs/pbd/undo.cc +++ b/libs/pbd/undo.cc @@ -152,11 +152,11 @@ UndoHistory::UndoHistory () } void -UndoHistory::set_depth (uint32_t d) +UndoHistory::set_depth (int32_t d) { _depth = d; - while (_depth > 0 && UndoList.size() > _depth) { + while (_depth > 0 && UndoList.size() > (uint32_t) _depth) { UndoList.pop_front (); } } @@ -166,7 +166,7 @@ UndoHistory::add (UndoTransaction* const ut) { ut->GoingAway.connect (bind (mem_fun (*this, &UndoHistory::remove), ut)); - while (_depth > 0 && UndoList.size() > _depth) { + while (_depth > 0 && UndoList.size() > (uint32_t) _depth) { UndoList.pop_front (); } @@ -253,17 +253,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 */ |