From 751dea75d3037756c4786f0020ab75cd7aeceb5d Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 11 Nov 2025 12:54:37 -0700 Subject: [PATCH] use drop_and_kill() when connecting Commands to their dependents --- libs/pbd/pbd/sequence_property.h | 4 ++-- libs/pbd/stateful_diff_command.cc | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/libs/pbd/pbd/sequence_property.h b/libs/pbd/pbd/sequence_property.h index b4843a1b03..377d834c1b 100644 --- a/libs/pbd/pbd/sequence_property.h +++ b/libs/pbd/pbd/sequence_property.h @@ -171,8 +171,8 @@ class /*LIBPBD_API*/ SequenceProperty : public PropertyBase with this diff(). */ - for (typename ChangeContainer::const_iterator i = a->changes().added.begin(); i != a->changes().added.end(); ++i) { - (*i)->DropReferences.connect_same_thread (*cmd, std::bind (&Destructible::drop_references, cmd)); + for (auto const & change : a->changes().added) { + change->DropReferences.connect_same_thread (*cmd, std::bind (Destructible::drop_and_kill, cmd)); } } } diff --git a/libs/pbd/stateful_diff_command.cc b/libs/pbd/stateful_diff_command.cc index 26292852bf..6e39e16d75 100644 --- a/libs/pbd/stateful_diff_command.cc +++ b/libs/pbd/stateful_diff_command.cc @@ -42,7 +42,9 @@ StatefulDiffCommand::StatefulDiffCommand (std::shared_ptr be sure to notify owners of this command. */ - s->DropReferences.connect_same_thread (*this, std::bind (&Destructible::drop_references, this)); + if (!_changes || _changes->empty()) { + s->DropReferences.connect_same_thread (*this, std::bind (Destructible::drop_and_kill, this)); + } } StatefulDiffCommand::StatefulDiffCommand (std::shared_ptr s, XMLNode const& n) @@ -63,7 +65,9 @@ StatefulDiffCommand::StatefulDiffCommand (std::shared_ptr be sure to notify owners of this command. */ - s->DropReferences.connect_same_thread (*this, std::bind (&Destructible::drop_references, this)); + if (_changes->empty()) { + s->DropReferences.connect_same_thread (*this, std::bind (Destructible::drop_and_kill, this)); + } } StatefulDiffCommand::~StatefulDiffCommand ()