From aca340b81090277e1ab4f49bae9dff04fb9c9783 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Dec 2025 11:43:00 -0700 Subject: [PATCH] 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) mgmt of RouteGroup lifetimes. --- libs/ardour/ardour/route_group.h | 2 +- libs/ardour/route_group.cc | 2 ++ libs/ardour/session.cc | 2 ++ libs/ardour/session_state.cc | 1 - 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/libs/ardour/ardour/route_group.h b/libs/ardour/ardour/route_group.h index 446f76c0c1..2deaab4206 100644 --- a/libs/ardour/ardour/route_group.h +++ b/libs/ardour/ardour/route_group.h @@ -147,7 +147,7 @@ public: /** Emitted when a route has been added to this group */ PBD::Signal )> RouteAdded; /** Emitted when a route has been removed from this group */ - PBD::Signal )> RouteRemoved; + static PBD::Signal )> RouteRemoved; XMLNode& get_state () const; diff --git a/libs/ardour/route_group.cc b/libs/ardour/route_group.cc index e5b532f980..73392e662a 100644 --- a/libs/ardour/route_group.cc +++ b/libs/ardour/route_group.cc @@ -64,6 +64,8 @@ namespace ARDOUR { } } +PBD::Signal )> RouteGroup::RouteRemoved; + void RouteGroup::make_property_quarks () { diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 4372cc1c20..b97f7b686b 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -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)); diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index aa4095c036..075a67a1fd 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -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 ();