Don't add Bundles to PortMatrix if they only have mistyped ports
authorJulien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>
Tue, 19 Jul 2016 00:03:44 +0000 (02:03 +0200)
committerJulien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>
Tue, 19 Jul 2016 00:10:40 +0000 (02:10 +0200)
PortMatrix is able to filter out ports that have an unwanted datatype, but
if a Bundle is added that has no port at all with a wanted datatype then
it is not weeded out correctly (and even if it were, there's no chance
that it will legitimately appear in the UI). Don't add that kind of
Bundle in the first place.

gtk2_ardour/port_group.cc

index f7b18156dcff16f65c9767a55533804bdb9426aa..084514363a3bd90ff0d5af2b51f5fb66be9fa942 100644 (file)
@@ -375,10 +375,7 @@ PortGroupList::gather (ARDOUR::Session* session, ARDOUR::DataType type, bool inp
        /* Sort RouteIOs by the routes' editor order keys */
        route_ios.sort (RouteIOsComparator ());
 
-       /* Now put the bundles that belong to these sorted RouteIOs into the PortGroup.
-          Note that if the RouteIO's bundles are multi-type, we may make new Bundles
-          with only the ports of one type.
-       */
+       /* Now put the bundles that belong to these sorted RouteIOs into the PortGroup. */
 
        for (list<RouteIOs>::iterator i = route_ios.begin(); i != route_ios.end(); ++i) {
                TimeAxisView* tv = PublicEditor::instance().axis_view_from_stripable (i->route);
@@ -392,10 +389,14 @@ PortGroupList::gather (ARDOUR::Session* session, ARDOUR::DataType type, bool inp
                }
 
                for (list<boost::shared_ptr<IO> >::iterator j = i->ios.begin(); j != i->ios.end(); ++j) {
-                       if (tv) {
-                               g->add_bundle ((*j)->bundle(), *j, tv->color ());
-                       } else {
-                               g->add_bundle ((*j)->bundle(), *j);
+                       /* Only add the bundle if there is at least one port
+                        * with a type that's been asked for */
+                       if (type == DataType::NIL || (*j)->bundle()->nchannels().n(type) > 0) {
+                               if (tv) {
+                                       g->add_bundle ((*j)->bundle(), *j, tv->color ());
+                               } else {
+                                       g->add_bundle ((*j)->bundle(), *j);
+                               }
                        }
                }
        }