Improve plugin hide logic to prevent crashes when trying to insert fully audio plugin...
authorCarl Hetherington <carl@carlh.net>
Wed, 19 Oct 2011 14:26:16 +0000 (14:26 +0000)
committerCarl Hetherington <carl@carlh.net>
Wed, 19 Oct 2011 14:26:16 +0000 (14:26 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@10232 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/plugin_insert.cc

index 78f65963302cd77ac90a0d756075385d95560343..1bdf7e32d08cf34002e806586d831f4530ee8bce 100644 (file)
@@ -803,17 +803,22 @@ PluginInsert::private_can_support_io_configuration (ChanCount const & in, ChanCo
           by feeding them silence.
        */
 
-       bool can_hide = false;
+       bool could_hide = false;
+       bool cannot_hide = false;
        ChanCount hide_channels;
        
        for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
                if (inputs.get(*t) > in.get(*t)) {
+                       /* there is potential to hide, since the plugin has more inputs of type t than the insert */
                        hide_channels.set (*t, inputs.get(*t) - in.get(*t));
-                       can_hide = true;
+                       could_hide = true;
+               } else if (inputs.get(*t) < in.get(*t)) {
+                       /* we definitely cannot hide, since the plugin has fewer inputs of type t than the insert */
+                       cannot_hide = true;
                }
        }
 
-       if (can_hide) {
+       if (could_hide && !cannot_hide) {
                out = outputs;
                return Match (Hide, 1, hide_channels);
        }