Fix duplicate UI initialization

When loading the very first session is canceled (e.g.
sample-rate mismatch -> Do not load session) or fails otherwise,
execution returns to the startupFSM.

Loading another session after that then takes the same path again:

StartupFSM::dialog_response_handler() -> StartupFSM::engine_running()
-> ARDOUR_UI::attach_to_engine()

The call needs to be idempotent, otherwise setup_windows(),
create_editor() etc are called a second time and Ardour crashes.
This commit is contained in:
Robin Gareus 2022-08-06 21:44:55 +02:00
parent fc54e9c583
commit 7408a9958e
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04

View file

@ -593,8 +593,13 @@ ARDOUR_UI::create_global_port_matrix (ARDOUR::DataType type)
void void
ARDOUR_UI::attach_to_engine () ARDOUR_UI::attach_to_engine ()
{ {
static bool first_time = true;
if (!first_time) {
return;
}
AudioEngine::instance()->Running.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::engine_running, this, _1), gui_context()); AudioEngine::instance()->Running.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::engine_running, this, _1), gui_context());
engine_running (0); engine_running (0);
first_time = false;
} }
void void