From 5d42509a215069d22828928dbb8c587c03316804 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 29 Nov 2022 20:03:44 +0100 Subject: [PATCH] Report error to user in startupFSM StartupFSM does not catch SessionException from Session::load_state, but bails out early, after checking `get_info_from_path` instead. So we have to explicitly report errors. --- gtk2_ardour/startup_fsm.cc | 57 ++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 11 deletions(-) diff --git a/gtk2_ardour/startup_fsm.cc b/gtk2_ardour/startup_fsm.cc index 5aca97b5da..21ea9ce819 100644 --- a/gtk2_ardour/startup_fsm.cc +++ b/gtk2_ardour/startup_fsm.cc @@ -591,10 +591,21 @@ StartupFSM::get_session_parameters_from_path (string const & path, string const string program_version; const string statefile_path = Glib::build_filename (session_path, session_name + ARDOUR::statefile_suffix); - if (Session::get_info_from_path (statefile_path, sr, fmt, program_version, &session_engine_hints)) { - /* exists but we can't read it correctly */ - error << string_compose (_("Cannot get existing session information from %1"), statefile_path) << endmsg; - return false; + switch (Session::get_info_from_path (statefile_path, sr, fmt, program_version, &session_engine_hints)) { + case 0: + /* OK */ + break; + case -1: + error << string_compose (_("Session file %1 does not exist"), statefile_path) << endmsg; + return false; + break; + case -3: + error << string_compose (_("Session %1 is from a newer version of %2"), statefile_path, PROGRAM_NAME) << endmsg; + return false; + break; + default: + error << string_compose (_("Cannot get existing session information from %1"), statefile_path) << endmsg; + return false; } session_existing_sample_rate = sr; @@ -717,10 +728,23 @@ StartupFSM::check_session_parameters (bool must_be_new) SampleFormat fmt; string program_version; const string statefile_path = Glib::build_filename (session_path, session_name + ARDOUR::statefile_suffix); - if (Session::get_info_from_path (statefile_path, sr, fmt, program_version, &session_engine_hints)) { - /* exists but we can't read it */ - return -1; + switch (Session::get_info_from_path (statefile_path, sr, fmt, program_version, &session_engine_hints)) { + case 0: + /* OK */ + break; + case -1: + error << string_compose (_("Session file %1 does not exist"), statefile_path) << endmsg; + return -1; + break; + case -3: + error << string_compose (_("Session %1 is from a newer version of %2"), statefile_path, PROGRAM_NAME) << endmsg; + return -1; + break; + default: + error << string_compose (_("Cannot get existing session information from %1"), statefile_path) << endmsg; + return -1; } + session_existing_sample_rate = sr; return 0; } @@ -832,10 +856,21 @@ StartupFSM::check_session_parameters (bool must_be_new) const string statefile_path = Glib::build_filename (session_path, session_name + ARDOUR::statefile_suffix); if (!session_is_new) { - - if (Session::get_info_from_path (statefile_path, sr, fmt, program_version, &session_engine_hints)) { - /* exists but we can't read it */ - return -1; + switch (Session::get_info_from_path (statefile_path, sr, fmt, program_version, &session_engine_hints)) { + case 0: + /* OK */ + break; + case -1: + error << string_compose (_("Session file %1 does not exist"), statefile_path) << endmsg; + return -1; + break; + case -3: + error << string_compose (_("Session %1 is from a newer version of %2"), statefile_path, PROGRAM_NAME) << endmsg; + return -1; + break; + default: + error << string_compose (_("Cannot get existing session information from %1"), statefile_path) << endmsg; + return -1; } session_existing_sample_rate = sr;