From 054e1c3c123a1cfb0c79c448eae0511ccd2d9178 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 3 Feb 2023 07:50:32 +0100 Subject: [PATCH] Retain pending state after recovery (#9215) After recovering from a crash, the user still needs to retain the option to ignore the changes that were done just before the crash after investigating them (or save them into a snapshot). Previously crash recovery unconditionally overwrote the session file (see discussion on bug tracker). --- libs/ardour/ardour/session.h | 1 - libs/ardour/session.cc | 7 +++---- libs/ardour/session_state.cc | 7 +++---- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 5bc5da4065..c4cd8657de 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -1600,7 +1600,6 @@ private: std::string _current_snapshot_name; XMLTree* state_tree; - bool state_was_pending; StateOfTheState _state_of_the_state; friend class StateProtector; diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 7ca57bf657..2e9ced7b22 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -239,7 +239,6 @@ Session::Session (AudioEngine &eng, , _session_dir (new SessionDirectory (fullpath)) , _current_snapshot_name (snapshot_name) , state_tree (0) - , state_was_pending (false) , _state_of_the_state (StateOfTheState (CannotSave | InitialConnecting | Loading)) , _save_queued (false) , _save_queued_pending (false) @@ -613,9 +612,9 @@ Session::destroy () { vector debug_pointers; - /* if we got to here, leaving pending capture state around - is a mistake. - */ + /* if we got to here, leaving pending state around + * is a mistake. + */ remove_pending_capture_state (); diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index ac5308226f..4e918e4b11 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -423,9 +423,6 @@ Session::session_loaded () if (_is_new) { save_state (""); - } else if (state_was_pending) { - save_state (""); - state_was_pending = false; } /* Now, finally, we can fill the playback buffers */ @@ -968,7 +965,7 @@ Session::load_state (string snapshot_name, bool from_template) delete state_tree; state_tree = 0; - state_was_pending = false; + bool state_was_pending = false; /* check for leftover pending state from a crashed capture attempt */ @@ -982,6 +979,8 @@ Session::load_state (string snapshot_name, bool from_template) boost::optional r = AskAboutPendingState(); if (r.value_or (1)) { state_was_pending = true; + } else { + remove_pending_capture_state (); } }