ValueTree::copyPropertiesAndChildrenFrom() gets stuck on while loop


I have a little bit of a problem with reloading an APVTS from Xml. This problem seems to crash JUCE.

There are 2 buttons, save and load.

Save will save a Parameter living in an AudioProcessorValueTreeState to an XML file on your desktop.
Load will reload said XML file and try to replace the current APVTS with the one from the XML.

There are a loadPreset() and savePreset() function in the AudioProcessor that do this.

The error happens in the loadPreset function, when
is called.

Inside the copyPropertiesAndChildrenFrom() function happens a call to removeAllChildren which then uses a while loop to remove all Children from the ValueTree::SharedObject. This while loop seems to be getting stuck and the children never actually get removed from my tree.

I consulted on another forum with this problem already and @matkatmusic was able to recreate the problem with my sample code.

Can anyone else reproduce this?

The code, as it is on the git repo right now causes my RAM to explode… Am I doing something wrong or is this a deeper problem with this function?

1 Like

Verified that this bug happens.
if the line copyPropertiesAndChildrenFrom() is replaced with copyPropertiesFrom(), the hang doesn’t happen, and the saved xml tree is identical to the loaded xml tree, when generated from this single-parameter plugin test.

@jules you provided this function that’s hanging with commit eb9341. any ideas?

I’m not seeing a hang with the test project, but I can see that it hits an assertion in AudioProcessorValueTreeState::setNewState(). Can you try the project with this commit and see if the issue is still present?

1 Like

Yeah that works… without that setNewState() call in valueTreeChildRemoved() nothing hangs and everything is working as it should…