changes to RouteGroup API and mgmt to make explicit group removal work

This commit is contained in:
Paul Davis 2025-12-16 12:05:22 -07:00
parent 321e8c368b
commit db6005945f
5 changed files with 29 additions and 6 deletions

View file

@ -115,6 +115,7 @@ class LIBARDOUR_API RouteGroup : public SessionObject, public std::enable_shared
int add (std::shared_ptr<Route>);
int remove (std::shared_ptr<Route>);
void clear ();
template<typename Function> void foreach_route (Function f) { for (auto & r : *routes) {f (r); } }
@ -126,11 +127,6 @@ class LIBARDOUR_API RouteGroup : public SessionObject, public std::enable_shared
void audio_track_group (std::set<std::shared_ptr<AudioTrack> >& at_set);
void clear () {
routes->clear ();
changed();
}
bool has_subgroup() const;
bool can_subgroup (bool, Placement) const;
void make_subgroup (bool, Placement);

View file

@ -1946,6 +1946,7 @@ private:
int load_route_groups (const XMLNode&, int);
RouteGroupList _route_groups;
void route_group_emptied (std::shared_ptr<RouteGroup>);
/* routes stuff */

View file

@ -244,6 +244,18 @@ RouteGroup::unset_subgroup_bus ()
_subgroup_bus.reset ();
}
void
RouteGroup::clear ()
{
RouteList copy (*routes);
for (auto & r : copy) {
remove (r);
}
changed ();
}
int
RouteGroup::remove (std::shared_ptr<Route> r)
{

View file

@ -6829,8 +6829,10 @@ Session::route_removed_from_route_group (std::shared_ptr<RouteGroup> rg, std::we
update_route_record_state ();
RouteRemovedFromRouteGroup (rg, r); /* EMIT SIGNAL */
std::shared_ptr<Route> rr (r.lock());
if (!rg->has_control_master () && !rg->has_subgroup () && rg->empty()) {
remove_route_group (rg);
route_group_emptied (rg);
}
}

View file

@ -3608,6 +3608,18 @@ Session::add_route_group (std::shared_ptr<RouteGroup> g)
void
Session::remove_route_group (std::shared_ptr<RouteGroup> rg)
{
if (!rg) {
return;
}
rg->clear ();
/* by the magic of reference counting, rg will now be deleted */
}
void
Session::route_group_emptied (std::shared_ptr<RouteGroup> rg)
{
list<std::shared_ptr<RouteGroup>>::iterator i;