fix save_as()' inadvertent marking a session as dirty during the process of saving...
authorPaul Davis <paul@linuxaudiosystems.com>
Thu, 9 Feb 2017 11:25:09 +0000 (12:25 +0100)
committerPaul Davis <paul@linuxaudiosystems.com>
Thu, 9 Feb 2017 11:40:59 +0000 (12:40 +0100)
libs/ardour/session_state.cc

index e0edfa6b2d6176d65a096d676f65990e0d3ec83b..b2d3fbb083976d15be79cabe4dfe750d4748d509 100644 (file)
@@ -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.
                        */