From cda2e004a88f99e7657b0a81852bb0cde16b4fa0 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 12 Jun 2020 22:08:04 +0200 Subject: [PATCH] Fix opening sessions using the Finder (OSX) The ShouldLoad() signal is handled by flush_pending(). This is the first time that normal application flow can be interrupted in ::starting() after app->ready(). This calls ::load_from_application_api(), which in turn calls startup_fsm->handle_path(). This sets off the complete initalization process, loading the session, and concludes with ::sfsm_response(), where there is a call to `delete startup_fsm;` Previously execution continued in StartupFSM::start() which caused a crash. --- gtk2_ardour/ardour_ui_startup.cc | 14 +++++++++++++- gtk2_ardour/startup_fsm.cc | 8 +++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/gtk2_ardour/ardour_ui_startup.cc b/gtk2_ardour/ardour_ui_startup.cc index ca470524c3..5b93b26be2 100644 --- a/gtk2_ardour/ardour_ui_startup.cc +++ b/gtk2_ardour/ardour_ui_startup.cc @@ -471,10 +471,11 @@ ARDOUR_UI::sfsm_response (StartupFSM::Result r) case StartupFSM::LoadSession: if (load_session_from_startup_fsm () == 0) { + startup_done (); delete startup_fsm; startup_fsm = 0; - startup_done (); } else { + DEBUG_TRACE (DEBUG::GuiStartup, "FSM reset\n"); startup_fsm->reset (); } @@ -519,6 +520,16 @@ ARDOUR_UI::starting () startup_fsm = new StartupFSM (*amd); startup_fsm->signal_response().connect (sigc::mem_fun (*this, &ARDOUR_UI::sfsm_response)); + + /* allow signals to be handled, ShouldLoad() from flush-pending */ + Splash::instance()->pop_front(); + flush_pending (); + + if (!startup_fsm) { + DEBUG_TRACE (DEBUG::GuiStartup, "Starting: SFSM was driven by flush-pending\n"); + return 0; + } + /* Note: entire startup process could happen in this one call * if: * @@ -788,6 +799,7 @@ ARDOUR_UI::load_from_application_api (const std::string& path) * 3) no audio/MIDI setup required */ + Splash::instance()->pop_front(); startup_fsm->start (); } } diff --git a/gtk2_ardour/startup_fsm.cc b/gtk2_ardour/startup_fsm.cc index a1fc5e6c02..c52b0ecea8 100644 --- a/gtk2_ardour/startup_fsm.cc +++ b/gtk2_ardour/startup_fsm.cc @@ -127,11 +127,6 @@ StartupFSM::queue_finish () void StartupFSM::start () { - /* get the splash screen visible, if it isn't yet */ - Splash::instance()->pop_front(); - /* make it all happen on-screen */ - ARDOUR_UI::instance()->flush_pending (); - DEBUG_TRACE (DEBUG::GuiStartup, string_compose (X_("State at startup: %1\n"), enum_2_string (_state))); switch (_state) { @@ -144,6 +139,9 @@ StartupFSM::start () case WaitingForSessionPath: handle_waiting_for_session_path (); break; + case WaitingForEngineParams: + start_audio_midi_setup (); + break; default: fatal << string_compose (_("Programming error: %1"), string_compose (X_("impossible starting state in StartupFSM (%1)"), enum_2_string (_state))) << endmsg; std::cerr << string_compose (_("Programming error: %1"), string_compose (X_("impossible starting state in StartupFSM (%1)"), enum_2_string (_state))) << std::endl;