Missing Safety Check in AudioProcessorGraph::addNode()


#1

Hi Jules,

This may seem bizarre, but there’s missing a minute safety check in AudioProcessorGraph::addNode: a check to make sure the processor isn’t the graph instance itself! (Copy/pasta errors make this really fun to track down)

AudioProcessorGraph::Node* AudioProcessorGraph::addNode (AudioProcessor* const newProcessor, uint32 nodeId)
{
    //==============================
    //Comme ça?
    if (newProcessor == this)
    {
        jassertfalse; //You're trying to add the graph instance to itself!
        return nullptr;
    }
    //==============================

    if (newProcessor == nullptr)
    {
        jassertfalse;
        return nullptr;
    }

    if (nodeId == 0)
    {
        nodeId = ++lastNodeId;
    }
    else
    {
        // you can't add a node with an id that already exists in the graph..
        jassert (getNodeForId (nodeId) == nullptr);
        removeNode (nodeId);

        if (nodeId > lastNodeId)
            lastNodeId = nodeId;
    }

    newProcessor->setPlayHead (getPlayHead());

    Node* const n = new Node (nodeId, newProcessor);
    nodes.add (n);
    triggerAsyncUpdate();

    n->setParentGraph (this);
    return n;
}

#2

Yes, will add that!