I am migrating my code from JUCE 5.4.3 to 5.4.4 and now my setStateInformation() and getStateInformation() both misbehave in 5.4.4.
Here is what I am doing in PluginProcessor.h. :
PluginProcessor()
#ifndef JucePlugin_PreferredChannelConfigurations
... ...
#endif
, parameters(*this, nullptr, "stabParams",
{ std::make_unique<AudioParameterFloat>("a", "Parameter A", NormalisableRange<float>(-100.0f, 100.0f), 0.0f),
std::make_unique<AudioParameterInt >("b", "Parameter B", 0, 5, 2) })
{}
void getStateInformation(MemoryBlock& destData)
{
pluginStateInfoXML.reset(parameters.state.createXml().get());
DBG("5.4.4. store XML: " << pluginStateInfoXML.get()->toString()); // "Exception thrown: read access violation. this->data was nullptr."
copyXmlToBinary(*pluginStateInfoXML.get(), destData);
}
void setStateInformation(const void* data, int sizeInBytes)
{
pluginStateInfoXML.reset(getXmlFromBinary(data, sizeInBytes).get());
DBG("5.4.4. restore XML: " << pluginStateInfoXML.get()->toString()); // "Exception thrown: read access violation. this->data was nullptr."
parameters.replaceState(ValueTree::fromXml(*pluginStateInfoXML.get()));
}
public:
std::unique_ptr<XmlElement> pluginStateInfoXML;
AudioProcessorValueTreeState parameters;
As commented in the quoted code, XmlElement::toString() call triggers an exception.
My question could be stated as:
Given the following code that works fine in JUCE 5.4.3:
void getStateInformation(MemoryBlock& destData) { pluginStateInfoXML.reset(parameters.state.createXml()); DBG("5.4.3. store XML: " << pluginStateInfoXML.get()->createDocument("")); copyXmlToBinary(*pluginStateInfoXML.get(), destData); }
void setStateInformation(const void* data, int sizeInBytes) { pluginStateInfoXML.reset(getXmlFromBinary(data, sizeInBytes)); DBG("5.4.3. restore XML: " << pluginStateInfoXML.get()->createDocument("")); parameters.replaceState(ValueTree::fromXml(*pluginStateInfoXML.get())); }
… what would be its equivalent that works in JUCE 5.4.4?

