From 0e28620a7afbbc0f9018c3c7df7e4d95fbc70311 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 24 Sep 2024 14:50:35 -0600 Subject: [PATCH] prevent Session::StateSaved being emitted when doing save-as with no switch-to The signal would be emitted while the session was temporarily renamed, making it appear that we had switched to the new session, despite instructions not to do so. We had not actually done so, but the saved-as name would show up on window titles. --- libs/ardour/ardour/session.h | 9 +++++---- libs/ardour/session_state.cc | 17 ++++++++++++++--- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index ebf15513a2..bfc029ff93 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -1633,10 +1633,11 @@ private: XMLTree* state_tree; StateOfTheState _state_of_the_state; - friend class StateProtector; - std::atomic _suspend_save; - volatile bool _save_queued; - volatile bool _save_queued_pending; + friend class StateProtector; + std::atomic _suspend_save; + volatile bool _save_queued; + volatile bool _save_queued_pending; + bool _no_save_signal; Glib::Threads::Mutex save_state_lock; Glib::Threads::Mutex save_source_lock; diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index c09ff047f3..f6851f9ba4 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -751,7 +751,9 @@ Session::remove_state (string snapshot_name) xml_path, g_strerror (errno)) << endmsg; } - StateSaved (snapshot_name); /* EMIT SIGNAL */ + if (!_no_save_signal) { + StateSaved (snapshot_name); /* EMIT SIGNAL */ + } } /** @param snapshot_name Name to save under, without .ardour / .pending prefix */ @@ -924,7 +926,9 @@ Session::save_state (string snapshot_name, bool pending, bool switch_to_snapshot unset_dirty (/* EMIT SIGNAL */ true); } - StateSaved (snapshot_name); /* EMIT SIGNAL */ + if (!_no_save_signal) { + StateSaved (snapshot_name); /* EMIT SIGNAL */ + } } #ifndef NDEBUG @@ -5544,11 +5548,18 @@ Session::save_as (SaveAs& saveas) store_recent_sessions (_name, _path); + std::cerr << "Saveas, switch to: " << saveas.switch_to << std::endl; + if (!saveas.switch_to) { + std::cerr << "no switch to!\n"; + /* save the new state */ - save_state ("", false, false, !saveas.include_media); + { + PBD::Unwinder uw (_no_save_signal, true); + save_state ("", false, false, !saveas.include_media); + } /* switch back to the way things were */