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.
This commit is contained in:
Paul Davis 2025-11-11 12:52:54 -07:00
parent a1d5294af5
commit 210f58ddb7

View file

@ -30,7 +30,12 @@ public:
PBD::Signal<void()> Destroyed; PBD::Signal<void()> Destroyed;
PBD::Signal<void()> DropReferences; PBD::Signal<void()> DropReferences;
virtual void drop_references () { DropReferences(); } virtual void drop_references () { DropReferences(); }
static void drop_and_kill (Destructible* d) {
assert (d);
d->DropReferences();
delete d;
}
}; };
} }