From 71b6f1c9c445d0fc1ab2046f413345023ba8ae50 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gr=C3=A9goire=20KUBLER?= <gregoire.kubler@proton.me>
Date: Tue, 12 Mar 2024 15:43:26 +0100
Subject: [PATCH] fix : if Flatten was the root node then the graph has no root
 node anymore after node deletion

---
 src/graph/GraphView.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/graph/GraphView.cpp b/src/graph/GraphView.cpp
index 005a7e679..34a6e8c55 100644
--- a/src/graph/GraphView.cpp
+++ b/src/graph/GraphView.cpp
@@ -912,6 +912,13 @@ bool Aidge::GraphView::replace(const std::shared_ptr<GraphView>& oldG, const std
                 for (std::size_t i = 0; i < oldOI.size(); ++i) {
                     if (inputParents[i].first)
                         inputParents[i].first -> addChild(outputChildren[i].first, inputParents[i].second, outputChildren[i].second);
+                    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 ((oldOI.size() == 1) && (inputParents[0].first)) {
-- 
GitLab