From b5cc6ccab668c0f9a49915b7e301d208fedcd617 Mon Sep 17 00:00:00 2001 From: Olivier BICHLER <olivier.bichler@cea.fr> Date: Tue, 28 Nov 2023 23:14:12 +0100 Subject: [PATCH] Fixed iterator issue --- src/graph/GraphView.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/graph/GraphView.cpp b/src/graph/GraphView.cpp index f3095702b..3499bd093 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); -- GitLab