set owner or disk-i/o processors
[ardour.git] / libs / ardour / control_protocol_manager.cc
index 7205b3e79e18368b429b8b62e814a729263ee56c..c2929a396870a5dc1ba660812f70f97f51570832 100644 (file)
@@ -76,6 +76,7 @@ ControlProtocolManager::~ControlProtocolManager()
 
 
        for (list<ControlProtocolInfo*>::iterator p = control_protocol_info.begin(); p != control_protocol_info.end(); ++p) {
+               (*p)->protocol = 0; // protocol was already destroyed above.
                delete (*p);
        }
 
@@ -87,27 +88,11 @@ ControlProtocolManager::set_session (Session* s)
 {
        SessionHandlePtr::set_session (s);
 
-       if (_session) {
-
-               /* get selection info and set it before instantiating any
-                * control protocols.
-                */
-
-               CoreSelection::StripableAutomationControls sac;
-               _session->selection().get_stripables (sac);
-
-               if (!sac.empty()) {
-                       StripableNotificationListPtr v (new StripableNotificationList);
-                       for (CoreSelection::StripableAutomationControls::iterator i = sac.begin(); i != sac.end(); ++i) {
-                               if ((*i).stripable) {
-                                       v->push_back (boost::weak_ptr<Stripable> ((*i).stripable));
-                               }
-                       }
-                       if (!v->empty()) {
-                               StripableSelectionChanged (v); /* EMIT SIGNAL */
-                       }
-               }
+       if (!_session) {
+               return;
+       }
 
+       {
                Glib::Threads::RWLock::ReaderLock lm (protocols_lock);
 
                for (list<ControlProtocolInfo*>::iterator i = control_protocol_info.begin(); i != control_protocol_info.end(); ++i) {
@@ -116,6 +101,21 @@ ControlProtocolManager::set_session (Session* s)
                        }
                }
        }
+
+       CoreSelection::StripableAutomationControls sac;
+       _session->selection().get_stripables (sac);
+
+       if (!sac.empty()) {
+               StripableNotificationListPtr v (new StripableNotificationList);
+               for (CoreSelection::StripableAutomationControls::iterator i = sac.begin(); i != sac.end(); ++i) {
+                       if ((*i).stripable) {
+                               v->push_back (boost::weak_ptr<Stripable> ((*i).stripable));
+                       }
+               }
+               if (!v->empty()) {
+                       StripableSelectionChanged (v); /* EMIT SIGNAL */
+               }
+       }
 }
 
 int
@@ -483,7 +483,9 @@ ControlProtocolManager::set_state (const XMLNode& node, int /*version*/)
                        ControlProtocolInfo* cpi = cpi_by_name (name);
 
                        if (cpi) {
+#ifndef NDEBUG
                                std::cerr << "protocol " << name << " active ? " << active << std::endl;
+#endif
 
                                if (active) {
                                        delete cpi->state;