Set VST cache file mtime to be at least as new as the plugin
[ardour.git] / libs / ardour / control_protocol_manager.cc
index b510bd5aa7da6220a36765ea74b7ce36c93fb6e6..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,32 +88,34 @@ 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);
-
-               for (CoreSelection::StripableAutomationControls::iterator i = sac.begin(); i != sac.end(); ++i) {
-                       if ((*i).stripable) {
-                               cerr << "First selected being set to " << (*i).stripable->name() << endl;
-                               ControlProtocol::set_first_selected_stripable ((*i).stripable);
-                               break;
-                       }
-               }
+       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) {
                        if ((*i)->requested || (*i)->mandatory) {
                                (void) activate (**i);
                        }
                }
        }
+
+       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
@@ -480,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;