From 417bd3b34260c1339153236c1764181cc53769ee Mon Sep 17 00:00:00 2001 From: Tom Poole Date: Tue, 2 Aug 2022 10:14:29 +0100 Subject: [PATCH] ValueTree: Add early exit when copying a ValueTree to itself --- modules/juce_data_structures/values/juce_ValueTree.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/juce_data_structures/values/juce_ValueTree.cpp b/modules/juce_data_structures/values/juce_ValueTree.cpp index 241a558eec..251d9f69b5 100644 --- a/modules/juce_data_structures/values/juce_ValueTree.cpp +++ b/modules/juce_data_structures/values/juce_ValueTree.cpp @@ -669,6 +669,9 @@ void ValueTree::copyPropertiesFrom (const ValueTree& source, UndoManager* undoMa { jassert (object != nullptr || source.object == nullptr); // Trying to add properties to a null ValueTree will fail! + if (source == *this) + return; + if (source.object == nullptr) removeAllProperties (undoManager); else if (object != nullptr) @@ -679,6 +682,9 @@ void ValueTree::copyPropertiesAndChildrenFrom (const ValueTree& source, UndoMana { jassert (object != nullptr || source.object == nullptr); // Trying to copy to a null ValueTree will fail! + if (source == *this) + return; + copyPropertiesFrom (source, undoManager); removeAllChildren (undoManager);