Consolidate API, prefer ->running()
[ardour.git] / gtk2_ardour / plugin_dspload_window.cc
index e9b54380d25217dc71f79f53effcb92d27075d77..2e20f9dcc8949436f760e7cea31e464ff2f5d156 100644 (file)
@@ -62,6 +62,8 @@ PluginDSPLoadWindow::set_session (Session* s)
        ArdourWindow::set_session (s);
        if (!s) {
                drop_references ();
+       } else if (is_visible ()) {
+               refill_processors ();
        }
 }
 
@@ -107,12 +109,23 @@ PluginDSPLoadWindow::drop_references ()
                        delete *child;
                }
        }
+       _route_connections.drop_connections ();
+       _processor_connections.drop_connections ();
 }
 
 void
 PluginDSPLoadWindow::refill_processors ()
 {
        drop_references ();
+       if (!_session || _session->deletion_in_progress()) {
+               /* may be called from session d'tor, removing monitor-section w/plugin */
+               return;
+       }
+
+       _session->RouteAdded.connect (
+                       _route_connections, invalidator (*this), boost::bind (&PluginDSPLoadWindow::refill_processors, this), gui_context()
+                       );
+
        RouteList routes = _session->get_routelist ();
        for (RouteList::const_iterator i = routes.begin(); i != routes.end(); ++i) {
 
@@ -123,7 +136,7 @@ PluginDSPLoadWindow::refill_processors ()
                                );
 
                (*i)->DropReferences.connect (
-                               _route_connections, invalidator (*this), boost::bind (&PluginDSPLoadWindow::drop_references, this), gui_context()
+                               _route_connections, invalidator (*this), boost::bind (&PluginDSPLoadWindow::refill_processors, this), gui_context()
                                );
        }
 
@@ -144,7 +157,7 @@ PluginDSPLoadWindow::add_processor_to_display (boost::weak_ptr<Processor> w, std
        if (!pi) {
                return;
        }
-       p->DropReferences.connect (_processor_connections, MISSING_INVALIDATOR, boost::bind (&PluginDSPLoadWindow::drop_references, this), gui_context());
+       p->DropReferences.connect (_processor_connections, MISSING_INVALIDATOR, boost::bind (&PluginDSPLoadWindow::refill_processors, this), gui_context());
        PluginLoadStatsGui* plsg = new PluginLoadStatsGui (pi);
        
        std::string name = route_name + " - " + pi->name();