Fix console1 crashes when no surface is present

e.g. selecting a track causes a ControlNotFoundException
if the ctrl surface is enabled, but no hardware is connected.

terminate called after throwing an instance of 'ArdourSurface::ControlNotFoundExceptio

```
#0  0x00007ffff14d8c2e in __cxa_throw () at /lib/x86_64-linux-gnu/libstdc++.so.6
#1  0x00007fffe2b560a0 in ArdourSurface::Console1::get_button(ArdourSurface::Console1::ControllerID) const (this=0x61d0017e1c80, id=ArdourSurface::Console1::FOCUS1)
    at ../libs/surfaces/console1/console1.cc:928
#2  0x00007fffe2bfc647 in ArdourSurface::Console1::map_select() (this=0x61d0017e1c80) at ../libs/surfaces/console1/c1_operations.cc:653
#3  0x00007fffe2b55384 in ArdourSurface::Console1::map_stripable_state() (this=0x61d0017e1c80) at ../libs/surfaces/console1/console1.cc:832
#4  0x00007fffe2b541ab in ArdourSurface::Console1::set_current_stripable(std::shared_ptr<ARDOUR::Stripable>)
...
```

This does at least fix the crash. Ideally the surface would
only be enabled if there is hardware present.
This commit is contained in:
Robin Gareus 2023-10-19 21:58:28 +02:00
parent 31f42b9be5
commit 8f5df7ed28
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
3 changed files with 30 additions and 30 deletions

View File

@ -126,7 +126,7 @@ Console1::rude_solo (const uint32_t value)
} else {
try {
get_button (ControllerID::DISPLAY_ON)->set_led_state (false);
} catch (ControlNotFoundException& e) {
} catch (ControlNotFoundException const&) {
DEBUG_TRACE (DEBUG::Console1, "Button not found\n");
}
}
@ -551,7 +551,7 @@ Console1::map_bank ()
try {
get_button (PAGE_UP)->set_led_state (list_size > (current_bank + 1) * bank_size);
get_button (PAGE_DOWN)->set_led_state (current_bank > 0);
} catch (ControlNotFoundException& e) {
} catch (ControlNotFoundException const&) {
DEBUG_TRACE (DEBUG::Console1, "Button not found\n");
}
}
@ -662,7 +662,7 @@ Console1::map_shift (bool shift)
ControllerButton* controllerButton = get_button (PRESET);
controllerButton->set_led_state (shift);
map_stripable_state ();
} catch (ControlNotFoundException& e) {
} catch (ControlNotFoundException const&) {
DEBUG_TRACE (DEBUG::Console1, "Button not found\n");
}
}
@ -674,7 +674,7 @@ Console1::map_plugin_state (bool plugin_state)
try {
ControllerButton* controllerButton = get_button (TRACK_GROUP);
controllerButton->set_led_state (in_plugin_state);
} catch (ControlNotFoundException& e) {
} catch (ControlNotFoundException const&) {
DEBUG_TRACE (DEBUG::Console1, "Button not found\n");
}
if (!plugin_state) {
@ -700,7 +700,7 @@ Console1::map_solo ()
} else {
controllerButton->set_led_state (false);
}
} catch (ControlNotFoundException& e) {
} catch (ControlNotFoundException const&) {
DEBUG_TRACE (DEBUG::Console1, "Button not found\n");
}
}
@ -727,7 +727,7 @@ Console1::map_filter ()
->set_led_state (_current_stripable->filter_enable_controllable (true)
? _current_stripable->filter_enable_controllable (true)->get_value ()
: false);
} catch (ControlNotFoundException& e) {
} catch (ControlNotFoundException const&) {
DEBUG_TRACE (DEBUG::Console1, "Button not found\n");
}
}
@ -763,7 +763,7 @@ Console1::map_gate ()
->set_led_state (_current_stripable->gate_enable_controllable ()
? _current_stripable->gate_enable_controllable ()->get_value ()
: false);
} catch (ControlNotFoundException& e) {
} catch (ControlNotFoundException const&) {
DEBUG_TRACE (DEBUG::Console1, "Button not found\n");
}
}
@ -779,7 +779,7 @@ Console1::map_gate_scf ()
->set_led_state (_current_stripable->gate_key_filter_enable_controllable ()
? _current_stripable->gate_key_filter_enable_controllable ()->get_value ()
: false);
} catch (ControlNotFoundException& e) {
} catch (ControlNotFoundException const&) {
DEBUG_TRACE (DEBUG::Console1, "Button not found\n");
}
}
@ -795,7 +795,7 @@ Console1::map_gate_listen ()
->set_led_state (_current_stripable->gate_key_listen_controllable ()
? _current_stripable->gate_key_listen_controllable ()->get_value ()
: false);
} catch (ControlNotFoundException& e) {
} catch (ControlNotFoundException const&) {
DEBUG_TRACE (DEBUG::Console1, "Button not found\n");
}
}
@ -898,7 +898,7 @@ Console1::map_eq ()
get_button (EQ)->set_led_state (_current_stripable->eq_enable_controllable ()
? _current_stripable->eq_enable_controllable ()->get_value ()
: false);
} catch (ControlNotFoundException& e) {
} catch (ControlNotFoundException const&) {
DEBUG_TRACE (DEBUG::Console1, "Button not found\n");
}
}
@ -939,7 +939,7 @@ Console1::map_eq_low_shape ()
? _current_stripable->eq_shape_controllable (0)->get_value () == 0 ? 0 : 63
: 0;
get_button (ControllerID::LOW_SHAPE)->set_led_state (led_value);
} catch (ControlNotFoundException& e) {
} catch (ControlNotFoundException const&) {
DEBUG_TRACE (DEBUG::Console1, "Button not found\n");
}
}
@ -954,7 +954,7 @@ Console1::map_eq_high_shape ()
? _current_stripable->eq_shape_controllable (3)->get_value () == 0 ? 0 : 63
: 0;
get_button (ControllerID::HIGH_SHAPE)->set_led_state (led_value);
} catch (ControlNotFoundException& e) {
} catch (ControlNotFoundException const&) {
DEBUG_TRACE (DEBUG::Console1, "Button not found\n");
}
}
@ -972,7 +972,7 @@ Console1::map_drive ()
DEBUG_TRACE (DEBUG::Console1, string_compose ("map_drive audio track %1\n", val));
try {
get_encoder (controllerID)->set_value (val == 1 ? 127 : 0);
} catch (ControlNotFoundException& e) {
} catch (ControlNotFoundException const&) {
DEBUG_TRACE (DEBUG::Console1, "Encoder not found\n");
}
} else {
@ -1016,7 +1016,7 @@ Console1::map_comp ()
->set_led_state (_current_stripable->comp_enable_controllable ()
? _current_stripable->comp_enable_controllable ()->get_value ()
: false);
} catch (ControlNotFoundException& e) {
} catch (ControlNotFoundException const&) {
DEBUG_TRACE (DEBUG::Console1, "Button not found\n");
}
}
@ -1032,7 +1032,7 @@ Console1::map_comp_mode ()
: false;
DEBUG_TRACE (DEBUG::Console1, string_compose ("****value from comp-type %1\n", value));
get_mbutton (ControllerID::ORDER)->set_led_state (value);
} catch (ControlNotFoundException& e) {
} catch (ControlNotFoundException const&) {
DEBUG_TRACE (DEBUG::Console1, "Button not found\n");
}
}
@ -1103,7 +1103,7 @@ Console1::map_encoder (ControllerID controllerID)
if (!_current_stripable) {
try {
get_encoder (controllerID)->set_value (0);
} catch (ControlNotFoundException& e) {
} catch (ControlNotFoundException const&) {
DEBUG_TRACE (DEBUG::Console1, "Encoder not found\n");
return false;
}
@ -1119,7 +1119,7 @@ Console1::map_encoder (ControllerID controllerID, std::shared_ptr<ARDOUR::Automa
if (!_current_stripable) {
try {
get_encoder (controllerID)->set_value (0);
} catch (ControlNotFoundException& e) {
} catch (ControlNotFoundException const&) {
DEBUG_TRACE (DEBUG::Console1, "Encoder not found\n");
}
return;
@ -1136,7 +1136,7 @@ Console1::map_encoder (ControllerID controllerID, std::shared_ptr<ARDOUR::Automa
}
try {
get_encoder (controllerID)->set_value (gain);
} catch (ControlNotFoundException& e) {
} catch (ControlNotFoundException const&) {
DEBUG_TRACE (DEBUG::Console1, "Encoder not found\n");
}
}
}

View File

@ -337,7 +337,7 @@ Console1::spill_plugins (const int32_t plugin_index)
plugin_insert->ActiveChanged.connect (
plugin_connections, MISSING_INVALIDATOR, boost::bind (plugin_mapping), this);
plugin_insert->ActiveChanged ();
} catch (ControlNotFoundException&) {
} catch (ControlNotFoundException const&) {
DEBUG_TRACE (DEBUG::Console1, string_compose ("No ControllerButton found %1\n", n_controls));
}
PluginMappingMap::iterator pmmit = pluginMappingMap.find (plugin->unique_id ());
@ -409,7 +409,7 @@ Console1::spill_plugins (const int32_t plugin_index)
plugin_connections, MISSING_INVALIDATOR, boost::bind (plugin_mapping, _1, _2), this);
c->Changed (true, PBD::Controllable::GroupControlDisposition::UseGroup);
continue;
} catch (ControlNotFoundException&) {
} catch (ControlNotFoundException const&) {
DEBUG_TRACE (DEBUG::Console1, string_compose ("No Encoder found %1\n", n_controls));
}
} else {
@ -436,7 +436,7 @@ Console1::spill_plugins (const int32_t plugin_index)
plugin_connections, MISSING_INVALIDATOR, boost::bind (plugin_mapping, _1, _2), this);
c->Changed (true, PBD::Controllable::GroupControlDisposition::UseGroup);
continue;
} catch (ControlNotFoundException&) {
} catch (ControlNotFoundException const&) {
DEBUG_TRACE (DEBUG::Console1, string_compose ("No ControllerButton found %1\n", n_controls));
}
}

View File

@ -457,7 +457,7 @@ Console1::handle_midi_controller_message (MIDI::Parser&, MIDI::EventTwoBytes* tb
e->action (value);
}
return;
} catch (ControlNotFoundException& e) {
} catch (ControlNotFoundException const&) {
DEBUG_TRACE (DEBUG::Console1,
string_compose ("handle_midi_controller_message: encoder not found cn: "
"'%1' val: '%2'\n",
@ -478,7 +478,7 @@ Console1::handle_midi_controller_message (MIDI::Parser&, MIDI::EventTwoBytes* tb
b->action (value);
}
return;
} catch (ControlNotFoundException& e) {
} catch (ControlNotFoundException const&) {
DEBUG_TRACE (DEBUG::Console1,
string_compose ("handle_midi_controller_message: button not found cn: "
"'%1' val: '%2'\n",
@ -495,7 +495,7 @@ Console1::handle_midi_controller_message (MIDI::Parser&, MIDI::EventTwoBytes* tb
}
return;
} catch (ControlNotFoundException& e) {
} catch (ControlNotFoundException const&) {
DEBUG_TRACE (DEBUG::Console1,
string_compose ("handle_midi_controller_message: mbutton not found cn: "
"'%1' val: '%2'\n",
@ -516,7 +516,7 @@ Console1::notify_solo_active_changed (bool state)
DEBUG_TRACE (DEBUG::Console1, "notify_active_solo_changed() \n");
try {
get_button (ControllerID::DISPLAY_ON)->set_led_value (state ? 127 : 0);
} catch (ControlNotFoundException& e) {
} catch (ControlNotFoundException const&) {
DEBUG_TRACE (DEBUG::Console1, "button not found");
}
}
@ -912,7 +912,7 @@ Console1::blinker ()
for (Blinkers::iterator b = blinkers.begin (); b != blinkers.end (); b++) {
try {
get_button (*b)->set_led_state (blink_state);
} catch (ControlNotFoundException& e) {
} catch (ControlNotFoundException const&) {
DEBUG_TRACE (DEBUG::Console1, "Blinking Button not found ...\n");
}
}
@ -1000,7 +1000,7 @@ Console1::periodic_update_meter ()
get_meter (OUTPUT_METER_R)->set_value (val_r);
last_output_meter_r = val_r;
}
} catch (ControlNotFoundException& e) {
} catch (ControlNotFoundException const&) {
DEBUG_TRACE (DEBUG::Console1, "Meter not found ...\n");
}
}
@ -1017,7 +1017,7 @@ Console1::periodic_update_meter ()
get_meter (SHAPE_METER)->set_value (val);
last_gate_meter = val;
}
} catch (ControlNotFoundException& e) {
} catch (ControlNotFoundException const&) {
DEBUG_TRACE (DEBUG::Console1, "Meter not found ...\n");
}
}
@ -1036,7 +1036,7 @@ Console1::periodic_update_meter ()
val = val * 0.6 + last_comp_redux * 0.4;
get_meter (COMP_METER)->set_value (val);
}
} catch (ControlNotFoundException& e) {
} catch (ControlNotFoundException const&) {
DEBUG_TRACE (DEBUG::Console1, "Meter not found ...\n");
}
}