an initial fix for a crash occuring when deleting routes that lead to RouteGroup deletion

The RouteGroup containing the deleted routes emits the RouteRemoved signal; Session handles this
and if the RouteGroup is now empty, deletes the RouteGroup *while in the middle of the signal
emission process*. This deletes the Signal (since it was owned by the RouteGroup) which leads
to a crash inside the signal emission code, since that is now running "on" a deleted Signal
object.

This change simply makes that signal static, and so deleting the RouteGroup has no effect
on the Signal itself.

More changes to come related to better (shared_ptr<RouteGroup>) mgmt of RouteGroup lifetimes.
This commit is contained in:
Paul Davis 2025-12-11 11:43:00 -07:00
parent e664fa5e63
commit aca340b810
4 changed files with 5 additions and 2 deletions

View file

@ -147,7 +147,7 @@ public:
/** Emitted when a route has been added to this group */
PBD::Signal<void(RouteGroup *, std::weak_ptr<ARDOUR::Route> )> RouteAdded;
/** Emitted when a route has been removed from this group */
PBD::Signal<void(RouteGroup *, std::weak_ptr<ARDOUR::Route> )> RouteRemoved;
static PBD::Signal<void(RouteGroup *, std::weak_ptr<ARDOUR::Route> )> RouteRemoved;
XMLNode& get_state () const;

View file

@ -64,6 +64,8 @@ namespace ARDOUR {
}
}
PBD::Signal<void(RouteGroup *, std::weak_ptr<ARDOUR::Route> )> RouteGroup::RouteRemoved;
void
RouteGroup::make_property_quarks ()
{

View file

@ -520,6 +520,8 @@ Session::Session (AudioEngine &eng,
StartTimeChanged.connect_same_thread (*this, std::bind (&Session::start_time_changed, this, _1));
EndTimeChanged.connect_same_thread (*this, std::bind (&Session::end_time_changed, this, _1));
RouteGroup::RouteRemoved.connect_same_thread (*this, std::bind (&Session::route_removed_from_route_group, this, _1, _2));
LatentSend::ChangedLatency.connect_same_thread (*this, std::bind (&Session::send_latency_compensation_change, this));
LatentSend::QueueUpdate.connect_same_thread (*this, std::bind (&Session::update_send_delaylines, this));
Latent::DisableSwitchChanged.connect_same_thread (*this, std::bind (&Session::queue_latency_recompute, this));

View file

@ -3573,7 +3573,6 @@ Session::add_route_group (RouteGroup* g)
route_group_added (g); /* EMIT SIGNAL */
g->RouteAdded.connect_same_thread (*this, std::bind (&Session::route_added_to_route_group, this, _1, _2));
g->RouteRemoved.connect_same_thread (*this, std::bind (&Session::route_removed_from_route_group, this, _1, _2));
g->PropertyChanged.connect_same_thread (*this, std::bind (&Session::route_group_property_changed, this, g));
set_dirty ();