From 9773cfa92645f8caf8aa524a5e7f45bb4d4d1b24 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sun, 30 Oct 2016 17:35:21 +0100 Subject: [PATCH] Drop UpdateMidnam shared_ptr reference when the plugin is removed --- gtk2_ardour/midi_time_axis.cc | 11 ++++++++++- gtk2_ardour/midi_time_axis.h | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/gtk2_ardour/midi_time_axis.cc b/gtk2_ardour/midi_time_axis.cc index fb2cebcd7e..4e4b541977 100644 --- a/gtk2_ardour/midi_time_axis.cc +++ b/gtk2_ardour/midi_time_axis.cc @@ -426,6 +426,12 @@ MidiTimeAxisView::setup_midnam_patches () } } +void +MidiTimeAxisView::drop_instrument_ref () +{ + midnam_connection.drop_connections (); +} + void MidiTimeAxisView::update_patch_selector () { @@ -437,7 +443,10 @@ MidiTimeAxisView::update_patch_selector () boost::shared_ptr the_instrument (_route->the_instrument()); boost::shared_ptr pi = boost::dynamic_pointer_cast(the_instrument); if (pi && pi->plugin ()->has_midnam ()) { - midnam_connection.disconnect (); + midnam_connection.drop_connections (); + the_instrument->DropReferences.connect (midnam_connection, invalidator (*this), + boost::bind (&MidiTimeAxisView::drop_instrument_ref, this), + gui_context()); pi->plugin()->UpdateMidnam.connect (midnam_connection, invalidator (*this), boost::bind (&Plugin::read_midnam, pi->plugin ()), gui_context()); diff --git a/gtk2_ardour/midi_time_axis.h b/gtk2_ardour/midi_time_axis.h index 9d8bea4e3c..fe8a464875 100644 --- a/gtk2_ardour/midi_time_axis.h +++ b/gtk2_ardour/midi_time_axis.h @@ -120,7 +120,8 @@ private: void setup_midnam_patches (); void update_patch_selector (); - PBD::ScopedConnection midnam_connection; + void drop_instrument_ref (); + PBD::ScopedConnectionList midnam_connection; void model_changed(const std::string& model); void custom_device_mode_changed(const std::string& mode); -- 2.30.2