I get the following error using Visual Studio 2022 (Juce 6) on the following line inside struct AssignedBuffer
{
…
static AssignedBuffer createFree() noexcept { return { { freeNodeID(), 0 }
for (auto& o : node.outputs)
connections.push_back ({ { node.nodeID, o.thisChannel }, { o.otherNode->nodeID, o.otherChannel } });
}
|Error|C2665|‘std::vector<juce::AudioProcessorGraph::Connection,std::allocatorjuce::AudioProcessorGraph::Connection>::push_back’: no overloaded function could convert all the argument types|
Please ignore the AssignBuffers error above, I found the problem. The second can be solved by ceating a Connection and passing it, instead of the Connection constructor data.
One more problem.
The following code crashes during the XmlElement destructor. when leaving the block. Adding getKeyMappings Xml to pXml is what causes the problem.
std::unique_ptr pXml = std::make_unique(Prefs);
auto pElement = pCommandManager->getKeyMappings()->createXml(true);
Child elements are deleted automatically when their parent is deleted, so make sure the object that you pass in will not be deleted by anything else, and make sure it’s not already the child of another element.
By adding the pElement which is managed through the unique_ptr to the parent makes it double deleted.
The addChildElement should consume a unique_ptr instead and have the child moved into, but it doesn’t for historic reasons.
The solution is not to use get() but rather release() so that the unique_ptr doesn’t own the child any more: