Selection::get_stripables() needs to recurse into an Automatable's child Automatables...
[ardour.git] / libs / ardour / selection.cc
index 876056c3da81a7b55cfb3cebc46f7ffe859f1b86..2286c8375174e2129c3bd571d7f4d19247332245 100644 (file)
@@ -217,9 +217,11 @@ CoreSelection::get_stripables (StripableAutomationControls& sc) const
                boost::shared_ptr<AutomationControl> c;
 
                if (!s) {
+                       /* some global automation control, not owned by a Stripable */
                        c = session.automation_control_by_id ((*x).controllable);
                } else {
-                       c = s->automation_control ((*x).controllable);
+                       /* automation control owned by a Stripable or one of its children */
+                       c = s->automation_control_recurse ((*x).controllable);
                }
 
                if (s || c) {
@@ -249,10 +251,14 @@ CoreSelection::remove_stripable_by_id (PBD::ID const & id)
 {
        Glib::Threads::RWLock::WriterLock lm (_lock);
 
-       for (SelectedStripables::iterator x = _stripables.begin(); x != _stripables.end(); ++x) {
+       for (SelectedStripables::iterator x = _stripables.begin(); x != _stripables.end(); ) {
                if ((*x).stripable == id) {
-                       _stripables.erase (x);
-                       return;
+                       _stripables.erase (x++);
+                       /* keep going because there may be more than 1 pair of
+                          stripable/automation-control in the selection.
+                       */
+               } else {
+                       ++x;
                }
        }
 }