From 7408a9958e6e7d46f97a7787bb1aef5a5dc8560c Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 6 Aug 2022 21:44:55 +0200 Subject: [PATCH] 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. --- gtk2_ardour/ardour_ui.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 9dac19ca19..884685d605 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -593,8 +593,13 @@ ARDOUR_UI::create_global_port_matrix (ARDOUR::DataType type) void 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()); engine_running (0); + first_time = false; } void