From 9f939c9be64e92467eacccf044aceff679c5eb52 Mon Sep 17 00:00:00 2001 From: Gauthier Quesnel Date: Tue, 12 Nov 2024 15:44:48 +0100 Subject: [PATCH] app: fix tree-node simulation-editor The old algorithm destroy connection from or to another tree-node. --- app/gui/generic/simulation.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/app/gui/generic/simulation.cpp b/app/gui/generic/simulation.cpp index 626ea4fb..93523da5 100644 --- a/app/gui/generic/simulation.cpp +++ b/app/gui/generic/simulation.cpp @@ -1328,16 +1328,18 @@ static int show_connection(simulation& sim, auto et = list->end(); while (it != et) { - if (auto* mdl_dst = sim.models.try_to_get(it->model); - mdl_dst and - exists_model_in_tree_node(tn, *mdl_dst)) { - int out = make_output_node_id(sim.get_id(dyn), i); - int in = - make_input_node_id(it->model, it->port_index); - ImNodes::Link(con_id++, out, in); - ++it; - } else { + auto* mdl_dst = sim.models.try_to_get(it->model); + if (not mdl_dst) { it = list->erase(it); + } else { + if (exists_model_in_tree_node(tn, *mdl_dst)) { + auto out = + make_output_node_id(sim.get_id(dyn), i); + auto in = + make_input_node_id(it->model, it->port_index); + ImNodes::Link(con_id++, out, in); + } + ++it; } } }