From b572f1a61770abaa41e91ebe6b5988b6483d7f2b Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 9 Feb 2017 12:25:09 +0100 Subject: fix save_as()' inadvertent marking a session as dirty during the process of saving state to disk --- libs/ardour/session_state.cc | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index e0edfa6b2d..b2d3fbb083 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -4976,7 +4976,6 @@ Session::save_as (SaveAs& saveas) bool was_dirty = dirty (); - save_state ("", false, false, !saveas.include_media); save_default_options (); if (saveas.copy_media && saveas.copy_external) { @@ -4991,6 +4990,10 @@ Session::save_as (SaveAs& saveas) if (!saveas.switch_to) { + /* save the new state */ + + save_state ("", false, false, !saveas.include_media); + /* switch back to the way things were */ _path = old_path; @@ -5024,6 +5027,19 @@ Session::save_as (SaveAs& saveas) */ reset_write_sources (true, true); + /* creating new write sources marks the session as + dirty. If the new session is empty, then + save_state() thinks we're saving a template and will + not mark the session as clean. So do that here, + before we save state. + */ + + if (!saveas.include_media) { + _state_of_the_state = StateOfTheState (_state_of_the_state & ~Dirty); + } + + save_state ("", false, false, !saveas.include_media); + /* the copying above was based on actually discovering files, not just iterating over the sources list. But if we're going to switch to the new (copied) session, we need to change the paths in the sources also. */ -- cgit v1.2.3