From b86b95b98037d5265c212c1e95dfa3017e634333 Mon Sep 17 00:00:00 2001 From: jules Date: Wed, 14 Feb 2018 12:17:58 +0000 Subject: [PATCH] Fixed a bug in the ValueTree move constructor that could leave listeners pointing to a moved-from object --- modules/juce_data_structures/values/juce_ValueTree.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); }