From 003e68edd258051a9520cd83487813d7ad71e647 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 28 Feb 2020 07:31:43 +0100 Subject: [PATCH] Display recent session-load errors in the GUI Dumping errors to stderr only is not very useful. Particularly not on Windows and MacOS. Even though a user may not be able to address the issue, this can lead to better reports vs just printing "corrupt state". --- gtk2_ardour/ardour_ui_session.cc | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/gtk2_ardour/ardour_ui_session.cc b/gtk2_ardour/ardour_ui_session.cc index 42214fac6c..9c728a4a87 100644 --- a/gtk2_ardour/ardour_ui_session.cc +++ b/gtk2_ardour/ardour_ui_session.cc @@ -418,28 +418,34 @@ ARDOUR_UI::load_session_stage_two (const std::string& path, const std::string& s goto out; } catch (SessionException const& e) { + stringstream ss; + dump_errors (ss, 6); + dump_errors (cerr); + clear_errors (); ArdourMessageDialog msg (string_compose( - _("Session \"%1 (snapshot %2)\" did not load successfully:\n%3"), - path, snap_name, e.what()), - true, + _("Session \"%1 (snapshot %2)\" did not load successfully:\n%3%4%5"), + path, snap_name, e.what(), ss.str().empty() ? "" : "\n\n---", ss.str()), + false, Gtk::MESSAGE_INFO, BUTTONS_OK); msg.set_title (_("Loading Error")); msg.set_position (Gtk::WIN_POS_CENTER); - dump_errors (cerr); - (void) msg.run (); msg.hide (); goto out; } catch (...) { + stringstream ss; + dump_errors (ss, 6); + dump_errors (cerr); + clear_errors (); ArdourMessageDialog msg (string_compose( - _("Session \"%1 (snapshot %2)\" did not load successfully."), - path, snap_name), + _("Session \"%1 (snapshot %2)\" did not load successfully.%3%4"), + path, snap_name, ss.str().empty() ? "" : "\n\n---", ss.str()), true, Gtk::MESSAGE_INFO, BUTTONS_OK); @@ -447,8 +453,6 @@ ARDOUR_UI::load_session_stage_two (const std::string& path, const std::string& s msg.set_title (_("Loading Error")); msg.set_position (Gtk::WIN_POS_CENTER); - dump_errors (cerr); - (void) msg.run (); msg.hide (); @@ -611,20 +615,26 @@ ARDOUR_UI::build_session_stage_two (std::string const& path, std::string const& new_session = new Session (*AudioEngine::instance(), path, snap_name, bus_profile.master_out_channels > 0 ? &bus_profile : NULL, meta_session ? "" : session_template); } catch (SessionException const& e) { + stringstream ss; + dump_errors (ss, 6); cerr << "Here are the errors associated with this failed session:\n"; dump_errors (cerr); cerr << "---------\n"; - ArdourMessageDialog msg (string_compose(_("Could not create session in \"%1\": %2"), path, e.what())); + clear_errors (); + ArdourMessageDialog msg (string_compose(_("Could not create session in \"%1\": %2%3%4"), path, e.what(), ss.str().empty() ? "" : "\n\n---", ss.str())); msg.set_title (_("Loading Error")); msg.set_position (Gtk::WIN_POS_CENTER); msg.run (); return -1; } catch (...) { + stringstream ss; + dump_errors (ss, 6); cerr << "Here are the errors associated with this failed session:\n"; dump_errors (cerr); cerr << "---------\n"; - ArdourMessageDialog msg (string_compose(_("Could not create session in \"%1\""), path)); + clear_errors (); + ArdourMessageDialog msg (string_compose(_("Could not create session in \"%1\"%2%3"), path, ss.str().empty() ? "" : "\n\n---", ss.str())); msg.set_title (_("Loading Error")); msg.set_position (Gtk::WIN_POS_CENTER); msg.run ();