diff --git a/modules/juce_data_structures/values/juce_ValueTree.cpp b/modules/juce_data_structures/values/juce_ValueTree.cpp index 21ee4872ef..40d85d71e8 100644 --- a/modules/juce_data_structures/values/juce_ValueTree.cpp +++ b/modules/juce_data_structures/values/juce_ValueTree.cpp @@ -639,11 +639,13 @@ ValueTree& ValueTree::operator= (const ValueTree& other) ValueTree::ValueTree (ValueTree&& other) noexcept : object (static_cast (other.object)) { + if (object != nullptr) + object->valueTreesWithListeners.removeValue (&other); } ValueTree::~ValueTree() { - if (listeners.size() > 0 && object != nullptr) + if (! listeners.isEmpty() && object != nullptr) object->valueTreesWithListeners.removeValue (this); }