From c4084932fab7ceb32a7a62ec5206fff18173dc1f Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 20 Nov 2015 03:10:57 +0100 Subject: [PATCH] remember in-use snapshot/session name in instant.xml --- libs/ardour/ardour/session.h | 2 ++ libs/ardour/session_state.cc | 34 +++++++++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 5dcab164f8..8a8e8e72e3 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -1236,6 +1236,8 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop void graph_reordered (); /** current snapshot name, without the .ardour suffix */ + void set_snapshot_name (const std::string &); + void save_snapshot_name (const std::string &); std::string _current_snapshot_name; XMLTree* state_tree; diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 0cbb550d02..9e8f8dcf2d 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -807,8 +807,8 @@ Session::save_state (string snapshot_name, bool pending, bool switch_to_snapshot if (snapshot_name.empty()) { snapshot_name = _current_snapshot_name; } else if (switch_to_snapshot) { - _current_snapshot_name = snapshot_name; - } + set_snapshot_name (snapshot_name); + } assert (!snapshot_name.empty()); @@ -982,6 +982,8 @@ Session::load_state (string snapshot_name) } } + save_snapshot_name (snapshot_name); + return 0; } @@ -1459,6 +1461,7 @@ Session::set_state (const XMLNode& node, int version) update_route_record_state (); /* here beginneth the second phase ... */ + set_snapshot_name (_current_snapshot_name); StateReady (); /* EMIT SIGNAL */ @@ -3910,6 +3913,27 @@ Session::solo_cut_control() const return _solo_cut_control; } +void +Session::save_snapshot_name (const std::string & n) +{ + /* assure Stateful::_instant_xml is loaded + * add_instant_xml() only adds to existing data and defaults + * to use an empty Tree otherwise + */ + instant_xml ("LastUsedSnapshot"); + + XMLNode* last_used_snapshot = new XMLNode ("LastUsedSnapshot"); + last_used_snapshot->add_property ("name", string(n)); + add_instant_xml (*last_used_snapshot, false); +} + +void +Session::set_snapshot_name (const std::string & n) +{ + _current_snapshot_name = n; + save_snapshot_name (n); +} + int Session::rename (const std::string& new_name) { @@ -4111,7 +4135,7 @@ Session::rename (const std::string& new_name) } } - _current_snapshot_name = new_name; + set_snapshot_name (new_name); _name = new_name; set_dirty (); @@ -4607,7 +4631,7 @@ Session::save_as (SaveAs& saveas) _path = to_dir; - _current_snapshot_name = saveas.new_name; + set_snapshot_name (saveas.new_name); _name = saveas.new_name; if (saveas.include_media && !saveas.copy_media) { @@ -4650,7 +4674,7 @@ Session::save_as (SaveAs& saveas) _path = old_path; _name = old_name; - _current_snapshot_name = old_snapshot; + set_snapshot_name (old_snapshot); (*_session_dir) = old_sd; -- 2.30.2