diff --git a/src/graph/GraphView.cpp b/src/graph/GraphView.cpp index b203b60bb32f0feb9b76d73cd6953cf81bea5e56..d231376551126a835159844268dc47bb3e9e72bf 100644 --- a/src/graph/GraphView.cpp +++ b/src/graph/GraphView.cpp @@ -1416,7 +1416,7 @@ std::shared_ptr<Aidge::GraphView> Aidge::GraphView::cloneCallback(NodePtr(*clone } // For each node, convert old node -> new node connections - for (auto &oldToNewNode : oldToNewNodes) { + for (const auto &oldToNewNode : oldToNewNodes) { if (oldToNewNode.second == nullptr) { continue; // deleted node } @@ -1424,7 +1424,7 @@ std::shared_ptr<Aidge::GraphView> Aidge::GraphView::cloneCallback(NodePtr(*clone // Connect parent nodes. Nodes that were removed with cloneNode() are set to nullptr size_t parentId = 0; for (auto parent : oldToNewNode.first->inputs()) { - if (parent.first != nullptr) { + if (parent.first != nullptr && inView(parent.first)) { while (oldToNewNodes[parent.first] == nullptr) { // Find next valid parent in line, going backward in the graph AIDGE_INTERNAL_ASSERT(parent.first->getChildren().size() == 1); @@ -1460,7 +1460,7 @@ std::shared_ptr<Aidge::GraphView> Aidge::GraphView::cloneCallback(NodePtr(*clone newGraph->add(oldToNewNodes[mRootNode], false); } - for (auto &oldToNewNode : oldToNewNodes) { + for (const auto &oldToNewNode : oldToNewNodes) { if (oldToNewNode.second == nullptr) continue; // deleted node