From 210f58ddb798b816b2fa1f00b86beea838283a67 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 11 Nov 2025 12:52:54 -0700 Subject: [PATCH] add Destructible::drop_and_kill() This should be used when a Destructible-derived object needs to be deleted. Handlers of the DropReferences signal should not responsible for deleting the Destructible, since that would happen in the middle of signal emission. Instead, emit the DropReferences signal, then delete the Destructible. --- libs/pbd/pbd/destructible.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libs/pbd/pbd/destructible.h b/libs/pbd/pbd/destructible.h index 778ea3738e..ee6c675ee8 100644 --- a/libs/pbd/pbd/destructible.h +++ b/libs/pbd/pbd/destructible.h @@ -30,7 +30,12 @@ public: PBD::Signal Destroyed; PBD::Signal DropReferences; - virtual void drop_references () { DropReferences(); } + virtual void drop_references () { DropReferences(); } + static void drop_and_kill (Destructible* d) { + assert (d); + d->DropReferences(); + delete d; + } }; }