Drop UpdateMidnam shared_ptr reference when the plugin is removed
authorRobin Gareus <robin@gareus.org>
Sun, 30 Oct 2016 16:35:21 +0000 (17:35 +0100)
committerRobin Gareus <robin@gareus.org>
Sun, 30 Oct 2016 16:39:55 +0000 (17:39 +0100)
gtk2_ardour/midi_time_axis.cc
gtk2_ardour/midi_time_axis.h

index fb2cebcd7eca003f579aa9a3d835c0477f522c89..4e4b54197730830c375a2d8dbcec15df2d11a362 100644 (file)
@@ -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<Processor> the_instrument (_route->the_instrument());
                boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert>(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());
index 9d8bea4e3c920599781c506128f7cf1c7c3df5fb..fe8a464875a91b33e55d0581b0bf3cce0bd79f5d 100644 (file)
@@ -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);