Browse Source

Fixed a bug in the ValueTree move constructor that could leave listeners pointing to a moved-from object

tags/2021-05-28
jules 8 years ago
parent
commit
b86b95b980
1 changed files with 3 additions and 1 deletions
  1. +3
    -1
      modules/juce_data_structures/values/juce_ValueTree.cpp

+ 3
- 1
modules/juce_data_structures/values/juce_ValueTree.cpp View File

@@ -639,11 +639,13 @@ ValueTree& ValueTree::operator= (const ValueTree& other)
ValueTree::ValueTree (ValueTree&& other) noexcept ValueTree::ValueTree (ValueTree&& other) noexcept
: object (static_cast<SharedObject::Ptr&&> (other.object)) : object (static_cast<SharedObject::Ptr&&> (other.object))
{ {
if (object != nullptr)
object->valueTreesWithListeners.removeValue (&other);
} }
ValueTree::~ValueTree() ValueTree::~ValueTree()
{ {
if (listeners.size() > 0 && object != nullptr)
if (! listeners.isEmpty() && object != nullptr)
object->valueTreesWithListeners.removeValue (this); object->valueTreesWithListeners.removeValue (this);
} }


Loading…
Cancel
Save