From 127c621d490371f1d6ac4146a144de9266a3611c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20KUBLER?= <gregoire.kubler@proton.me> Date: Wed, 13 Mar 2024 15:18:31 +0100 Subject: [PATCH] fix : previous fix was incorrect. mRootNode is set in updateinputsoutputsdelete --- src/graph/GraphView.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/graph/GraphView.cpp b/src/graph/GraphView.cpp index 8e83dff09..0e9c906dd 100644 --- a/src/graph/GraphView.cpp +++ b/src/graph/GraphView.cpp @@ -923,11 +923,7 @@ bool Aidge::GraphView::replace(const std::shared_ptr<GraphView>& oldGraph, const for (std::size_t i = 0; i < oldOIn.size(); ++i) { if (inputParents[i].first) { inputParents[i].first -> addChild(outputChildren[i].first, inputParents[i].second, outputChildren[i].second); - } else { - for (auto & view : commonGraphViews){ - view->setRootNode( outputChildren[i].first); - } - } + } } } else if ((oldOIn.size() == 1) && (inputParents[0].first)) { @@ -937,7 +933,7 @@ bool Aidge::GraphView::replace(const std::shared_ptr<GraphView>& oldGraph, const } } else if ( // for tiling-like cases. The number of inputNodes changes but not outputNodes - ((oldOIn.size() == 1) || (newOIn.size() == 1)) && // (oldOI.size() == newOI.size()) already handled in Case 1 + ((oldOIn.size() == 1) || (newOIn.size() == 1)) && // (oldOIn.size() == newOI.size()) already handled in Case 1 ((oldOOut.size() == newOOut.size())) ) { // Case 2 @@ -1201,7 +1197,14 @@ void Aidge::GraphView::updateInputsOutputsDelete(std::shared_ptr<Node> deletedNo } if (deletedNode == mRootNode) { - mRootNode = nullptr; + const std::pair<std::vector<NodePtr>, size_t> ranked_nodes = getRankedNodes(); + if(ranked_nodes.second== 0 ) + { + mRootNode = nullptr; + } else { + // The new root node will be the second node in the order of ranked nodes + setRootNode(*std::next(ranked_nodes.first.cbegin(),1)); + } } } -- GitLab