diff --git a/src/graph/GraphView.cpp b/src/graph/GraphView.cpp index f3095702b6b8c37b04c0be3c22cbf736290f28bd..3499bd0935543827638d7995c98366ef047a863f 100644 --- a/src/graph/GraphView.cpp +++ b/src/graph/GraphView.cpp @@ -1233,7 +1233,7 @@ std::shared_ptr<Aidge::GraphView> Aidge::GraphView::cloneCallback(NodePtr(*clone // Update cloned graph inputs/outputs order to match initial graph order auto newInputNodes = mInputNodes; - for (auto it = newInputNodes.begin(); it != newInputNodes.end(); ++it) { + for (auto it = newInputNodes.begin(); it != newInputNodes.end(); ) { // If input node was removed, find next valid input while (oldToNewNodes[it->first] == nullptr) { // Removed node should have only one connected output, otherwise cloning is invalid @@ -1262,12 +1262,13 @@ std::shared_ptr<Aidge::GraphView> Aidge::GraphView::cloneCallback(NodePtr(*clone } else { it->first = oldToNewNodes[it->first]; + ++it; } } newGraph->setOrderedInputs(newInputNodes); auto newOutputNodes = mOutputNodes; - for (auto it = newOutputNodes.begin(); it != newOutputNodes.end(); ++it) { + for (auto it = newOutputNodes.begin(); it != newOutputNodes.end(); ) { // If output node was removed, find previous valid output while (oldToNewNodes[it->first] == nullptr) { // Removed node should have only one connected data input, otherwise cloning is invalid @@ -1287,6 +1288,7 @@ std::shared_ptr<Aidge::GraphView> Aidge::GraphView::cloneCallback(NodePtr(*clone } else { it->first = oldToNewNodes[it->first]; + ++it; } } newGraph->setOrderedOutputs(newOutputNodes);