13
0

Collect ctrl surface ports into single bundle

This prevents a crash on Windows (and optimized mac builds) in
~PortGroup() when a ctrl surface is disabled. Despite the bundle being a
shared_ptr, unloading the ctrl surface module (.dll, dylib), destroys
the shared_ptr<> (or rather the memory are where the shared_ptr is
stored). This later causes a segfault in ~shared_ptr<Bundle>
when the PortGroup is released.

It is also much nicer to have all the ctrl surface grouped into a common
Bundle, rather than having a lot of bundles each with a single unnamed
port.
This commit is contained in:
Robin Gareus 2024-07-18 18:20:37 +02:00
parent 2cdfdc9212
commit 0bf42af59d

View File

@ -523,16 +523,20 @@ PortGroupList::gather (ARDOUR::Session* session, ARDOUR::DataType type, bool inp
if ((type == DataType::MIDI || type == DataType::NIL)) {
ControlProtocolManager& m = ControlProtocolManager::instance ();
std::shared_ptr<Bundle> sf (new Bundle (_("Control Surface"), inputs));
for (list<ControlProtocolInfo*>::iterator i = m.control_protocol_info.begin(); i != m.control_protocol_info.end(); ++i) {
if ((*i)->protocol) {
list<std::shared_ptr<Bundle> > b = (*i)->protocol->bundles ();
for (list<std::shared_ptr<Bundle> >::iterator j = b.begin(); j != b.end(); ++j) {
if ((*j)->ports_are_inputs() == inputs) {
program->add_bundle (*j);
sf->add_channels_from_bundle (*j);
}
}
}
}
if (sf->n_total () > 0) {
program->add_bundle (sf);
}
}
/* virtual keyboard */