diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2012-06-26 01:55:53 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2012-06-26 01:55:53 +0000 |
commit | a054a74dd29197679eb6f67e6fcaa54df7d70810 (patch) | |
tree | f39ddcc0681218cbc58243955c6870f38bdc5ef9 /libs | |
parent | 06ad59e93647ed604b026bc1680919638f3a7edc (diff) |
disconnect from a Controllable when it is destroyed
git-svn-id: svn://localhost/ardour2/branches/3.0@12938 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r-- | libs/surfaces/generic_midi/midicontrollable.cc | 15 | ||||
-rw-r--r-- | libs/surfaces/generic_midi/midicontrollable.h | 4 |
2 files changed, 17 insertions, 2 deletions
diff --git a/libs/surfaces/generic_midi/midicontrollable.cc b/libs/surfaces/generic_midi/midicontrollable.cc index d39886e0fc..a6d0b1c5ac 100644 --- a/libs/surfaces/generic_midi/midicontrollable.cc +++ b/libs/surfaces/generic_midi/midicontrollable.cc @@ -30,6 +30,7 @@ #include "midi++/channel.h" #include "ardour/automation_control.h" +#include "ardour/midi_ui.h" #include "ardour/utils.h" #include "midicontrollable.h" @@ -76,7 +77,7 @@ MIDIControllable::MIDIControllable (GenericMidiControlProtocol* s, Port& p, Cont MIDIControllable::~MIDIControllable () { - drop_external_control (); + drop_controllable (); } int @@ -111,6 +112,7 @@ MIDIControllable::drop_external_control () void MIDIControllable::set_controllable (Controllable* c) { + drop_controllable (); controllable = c; } @@ -198,11 +200,22 @@ MIDIControllable::lookup_controllable() } controllable = c.get(); + controllable->Destroyed.connect (controllable_death_connection, MISSING_INVALIDATOR, + boost::bind (&MIDIControllable::drop_controllable, this), + MidiControlUI::instance()); return 0; } void +MIDIControllable::drop_controllable () +{ + drop_external_control (); + controllable_death_connection.disconnect (); + controllable = 0; +} + +void MIDIControllable::midi_sense_note (Parser &, EventTwoBytes *msg, bool /*is_on*/) { if (!controllable) { diff --git a/libs/surfaces/generic_midi/midicontrollable.h b/libs/surfaces/generic_midi/midicontrollable.h index 571f71edfe..ff4411a9ca 100644 --- a/libs/surfaces/generic_midi/midicontrollable.h +++ b/libs/surfaces/generic_midi/midicontrollable.h @@ -107,6 +107,7 @@ class MIDIControllable : public PBD::Stateful int midi_msg_id; /* controller ID or note number */ PBD::ScopedConnection midi_sense_connection[2]; PBD::ScopedConnection midi_learn_connection; + PBD::ScopedConnection controllable_death_connection; /** the type of MIDI message that is used for this control */ MIDI::eventType control_type; MIDI::byte control_additional; @@ -118,7 +119,8 @@ class MIDIControllable : public PBD::Stateful bool _bank_relative; int lookup_controllable(); - + void drop_controllable(); + void midi_receiver (MIDI::Parser &p, MIDI::byte *, size_t); void midi_sense_note (MIDI::Parser &, MIDI::EventTwoBytes *, bool is_on); void midi_sense_note_on (MIDI::Parser &p, MIDI::EventTwoBytes *tb); |