From db1821a363869000c2b6e797e768972554fafacd Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 21 Jun 2021 05:27:11 +0200 Subject: [PATCH] Fix crash when removing plugin with mapped controllable #8756 MidiControlUI drops the reference to a given controllable in its own thread. This can happen after the plugin is already destroyed (even though the PBD::Controllable still exists). --- libs/surfaces/generic_midi/midicontrollable.cc | 6 ++---- libs/surfaces/generic_midi/midicontrollable.h | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/libs/surfaces/generic_midi/midicontrollable.cc b/libs/surfaces/generic_midi/midicontrollable.cc index 136efc94b6..75cfec6da0 100644 --- a/libs/surfaces/generic_midi/midicontrollable.cc +++ b/libs/surfaces/generic_midi/midicontrollable.cc @@ -135,7 +135,7 @@ MIDIControllable::set_controllable (boost::shared_ptr c) return; } - controllable_death_connections.drop_connections (); + controllable_death_connection.disconnect (); if (c) { _controllable = c; @@ -148,9 +148,7 @@ MIDIControllable::set_controllable (boost::shared_ptr c) last_incoming = 256; if (c) { - c->DropReferences.connect (controllable_death_connections, MISSING_INVALIDATOR, - boost::bind (&MIDIControllable::drop_controllable, this), - MidiControlUI::instance()); + c->DropReferences.connect_same_thread (controllable_death_connection, boost::bind (&MIDIControllable::drop_controllable, this)); } } diff --git a/libs/surfaces/generic_midi/midicontrollable.h b/libs/surfaces/generic_midi/midicontrollable.h index 2f80ed9a30..507ef538be 100644 --- a/libs/surfaces/generic_midi/midicontrollable.h +++ b/libs/surfaces/generic_midi/midicontrollable.h @@ -134,7 +134,7 @@ private: int midi_msg_id; /* controller ID or note number */ PBD::ScopedConnection midi_sense_connection[2]; PBD::ScopedConnection midi_learn_connection; - PBD::ScopedConnectionList controllable_death_connections; + PBD::ScopedConnection controllable_death_connection; /** the type of MIDI message that is used for this control */ MIDI::eventType control_type; MIDI::byte control_additional;