Handle race condition when removing route before routeUI

This fixes a crash when removing the monitor section.
The monitor route goes away, but the GUI remains. The
IOButton may still process previously queued
cross-thread signals.

In many cases this was not an issue since the route's
memory was not immediately released or shared_ptr
destruction only happened a short time later.
This commit is contained in:
Robin Gareus 2023-07-14 19:03:32 +02:00
parent bedab69338
commit 2c48aabe08
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
1 changed files with 11 additions and 0 deletions

View File

@ -483,6 +483,9 @@ IOButton::port_pretty_name_changed (std::string pn)
void
IOButton::port_connected_or_disconnected (std::weak_ptr<Port> wa, std::weak_ptr<Port> wb)
{
if (!_route) {
return;
}
std::shared_ptr<Port> a = wa.lock ();
std::shared_ptr<Port> b = wb.lock ();
@ -702,6 +705,14 @@ IOButton::update ()
std::shared_ptr<ARDOUR::Bundle> bundle;
_bundle_connections.drop_connections ();
if (!_route) {
/* There may still be a signal queued before `set_route (0)` unsets the route
* and unsubscribes. invalidation only happens when the button is destroyed. */
set_text (_input ? _("Input") : _("Output"));
set_tooltip (this, "");
return;
}
set_label (*this, _route->session (), bundle, _input ? _route->input () : _route->output ());
if (bundle) {