Remove dangling plugin thru-connections
authorRobin Gareus <robin@gareus.org>
Sat, 16 Apr 2016 10:43:56 +0000 (12:43 +0200)
committerRobin Gareus <robin@gareus.org>
Sat, 16 Apr 2016 10:43:56 +0000 (12:43 +0200)
fixes crash when removing a thru-connected output

libs/ardour/plugin_insert.cc

index 646bf5e63a5519cd580ded16b3fe47153b2330a6..740fa5250640f5d8ab7f1aaeda49728ed2bc8178 100644 (file)
@@ -1172,7 +1172,7 @@ PluginInsert::sanitize_maps ()
        /* strip dead wood */
        PinMappings new_ins;
        PinMappings new_outs;
-       ChanMapping new_thru (_thru_map);
+       ChanMapping new_thru;
 
        for (uint32_t pc = 0; pc < get_count(); ++pc) {
                ChanMapping new_in;
@@ -1216,6 +1216,17 @@ PluginInsert::sanitize_maps ()
                }
        }
 
+       /* remove excess thru */
+       for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
+               for (uint32_t o = 0; o < _configured_out.get (*t); ++o) {
+                       bool valid;
+                       uint32_t idx = _thru_map.get (*t, o, &valid);
+                       if (valid && idx < _configured_internal.get (*t)) {
+                               new_thru.set (*t, o, idx);
+                       }
+               }
+       }
+
        /* prevent out + thru,  existing plugin outputs override thru */
        for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
                for (uint32_t o = 0; o < _configured_out.get (*t); ++o) {