From 03e3546422b145363482648ac9a5a0cc80278dac Mon Sep 17 00:00:00 2001 From: Holger Dehnhardt Date: Sat, 28 Oct 2023 13:56:39 +0200 Subject: [PATCH] Clean init process to prevent exceptions --- libs/surfaces/console1/console1.cc | 47 +++++++++++++++--------------- libs/surfaces/console1/wscript | 2 +- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/libs/surfaces/console1/console1.cc b/libs/surfaces/console1/console1.cc index 408ae956f5..ad44fb28cb 100644 --- a/libs/surfaces/console1/console1.cc +++ b/libs/surfaces/console1/console1.cc @@ -98,8 +98,6 @@ Console1::set_active (bool yn) ControlProtocol::set_active (yn); - DEBUG_TRACE (DEBUG::Console1, string_compose ("Console1::set_active done with yn: '%1'\n", yn)); - return 0; } @@ -187,16 +185,30 @@ Console1::begin_using_device () Glib::RefPtr periodic_timer = Glib::TimeoutSource::create (100); periodic_connection = periodic_timer->connect (sigc::mem_fun (*this, &Console1::periodic)); periodic_timer->attach (main_loop ()->get_context ()); + connect_session_signals (); + connect_internal_signals (); + create_strip_inventory (); DEBUG_TRACE (DEBUG::Console1, "************** begin_using_device() ********************\n"); - create_strip_inventory (); - connect_internal_signals (); - stripable_selection_changed (); - return MIDISurface::begin_using_device (); } +int +Console1::stop_using_device () +{ + DEBUG_TRACE (DEBUG::Console1, "stop_using_device()\n"); + if (!_in_use) + return 0; + blink_connection.disconnect (); + periodic_connection.disconnect (); + stripable_connections.drop_connections (); + session_connections.drop_connections (); + console1_connections.drop_connections (); + MIDISurface::stop_using_device (); + return 0; +} + void Console1::connect_session_signals () { @@ -407,19 +419,6 @@ Console1::setup_controls () new Meter (this, ControllerID::OUTPUT_METER_R, boost::function ([] () {})); } -int -Console1::stop_using_device () -{ - DEBUG_TRACE (DEBUG::Console1, "stop_using_device()\n"); - - blink_connection.disconnect (); - periodic_connection.disconnect (); - stripable_connections.drop_connections (); - console1_connections.drop_connections (); - MIDISurface::stop_using_device (); - return 0; -} - void Console1::handle_midi_controller_message (MIDI::Parser&, MIDI::EventTwoBytes* tb) { @@ -513,6 +512,9 @@ void Console1::stripable_selection_changed () { DEBUG_TRACE (DEBUG::Console1, "stripable_selection_changed \n"); + if (!_in_use) + return; + std::shared_ptr r = ControlProtocol::first_selected_stripable (); if (r) { set_current_stripable (r); @@ -1194,11 +1196,10 @@ Console1::select_rid_by_index (uint32_t index) std::shared_ptr s = session->get_remote_nth_stripable (rid, PresentationInfo::MixerStripables); if (s) { session->selection ().select_stripable_and_maybe_group (s, true, false, 0); + } else { + success = false; } - else { - success = false; - } - if( !success ){ + if (!success) { map_select (); } } diff --git a/libs/surfaces/console1/wscript b/libs/surfaces/console1/wscript index e7c0b24505..0df65151e0 100644 --- a/libs/surfaces/console1/wscript +++ b/libs/surfaces/console1/wscript @@ -22,7 +22,7 @@ def build(bld): obj.includes = [ '.', './console1'] obj.name = 'libardour_console1' obj.target = 'ardour_console1' - obj.uselib = 'SIGCPP XML OSX' + obj.uselib = 'GTKMM SIGCPP XML OSX' obj.use = 'libardour libardour_cp libardour_midisurface libgtkmm2ext libpbd libevoral libtemporal' obj.install_path = os.path.join(bld.env['LIBDIR'], 'surfaces')