delete _control_outs;
_control_outs = new IO (_session, coutname);
- _control_outs->set_state (**(child->children().begin()));
+ /* fix up the control out name in the XML before setting it.
+ Otherwise track templates don't work because the control
+ outs end up with the stored template name, rather than
+ the new name of the track based on the template.
+ */
+
+ XMLProperty* prop = (*child->children().begin())->property ("name");
+ if (prop) {
+ prop->set_value (coutname);
+ }
+
+ _control_outs->set_state (**(child->children().begin()));
+
} else if (child->name() == X_("Comment")) {
/* XXX this is a terrible API design in libxml++ */