1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

AudioProcessorGraph: Allow nodes with ID 0 to be added

This commit is contained in:
Anthony Nicholls 2023-12-08 17:24:50 +00:00
parent a8c114b570
commit b91fec7787
3 changed files with 28 additions and 4 deletions

View file

@ -1694,7 +1694,7 @@ public:
}
Node::Ptr addNode (std::unique_ptr<AudioProcessor> newProcessor,
const NodeID nodeID,
std::optional<NodeID> nodeID,
UpdateKind updateKind)
{
if (newProcessor.get() == owner)
@ -1703,7 +1703,7 @@ public:
return nullptr;
}
const auto idToUse = nodeID == NodeID() ? NodeID { ++(lastNodeID.uid) } : nodeID;
const auto idToUse = nodeID.value_or (NodeID { lastNodeID.uid + 1 });
auto added = nodes.addNode (std::move (newProcessor), idToUse);
@ -1957,7 +1957,7 @@ bool AudioProcessorGraph::isAnInputTo (const Node& source, const Node& destinati
bool AudioProcessorGraph::isAnInputTo (NodeID source, NodeID destination) const noexcept { return pimpl->isAnInputTo (source, destination); }
AudioProcessorGraph::Node::Ptr AudioProcessorGraph::addNode (std::unique_ptr<AudioProcessor> newProcessor,
NodeID nodeId,
std::optional<NodeID> nodeId,
UpdateKind updateKind)
{
return pimpl->addNode (std::move (newProcessor), nodeId, updateKind);

View file

@ -252,7 +252,7 @@ public:
If this succeeds, it returns a pointer to the newly-created node.
*/
Node::Ptr addNode (std::unique_ptr<AudioProcessor> newProcessor, NodeID nodeId = {}, UpdateKind = UpdateKind::sync);
Node::Ptr addNode (std::unique_ptr<AudioProcessor> newProcessor, std::optional<NodeID> nodeId = std::nullopt, UpdateKind = UpdateKind::sync);
/** Deletes a node within the graph which has the specified ID.
This will also delete any connections that are attached to this node.