son't try to select non-existent notes after editing (and thus crash).
[ardour.git] / gtk2_ardour / midi_time_axis.cc
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());