From 0bf42af59d7cab79fab444d805d7c7c5cf296ab7 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 18 Jul 2024 18:20:37 +0200 Subject: [PATCH] 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 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. --- gtk2_ardour/port_group.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gtk2_ardour/port_group.cc b/gtk2_ardour/port_group.cc index 334d2348f1..790f64b249 100644 --- a/gtk2_ardour/port_group.cc +++ b/gtk2_ardour/port_group.cc @@ -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 sf (new Bundle (_("Control Surface"), inputs)); for (list::iterator i = m.control_protocol_info.begin(); i != m.control_protocol_info.end(); ++i) { if ((*i)->protocol) { list > b = (*i)->protocol->bundles (); for (list >::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 */