From bfd62d7cdff28f67c786b3135e01374d672e71de Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Tue, 14 Nov 2023 07:11:48 +1100 Subject: [PATCH] Visual shader refacter use of connection --- scene/resources/visual_shader.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp index 423ef3867f7f..9fb6b364a7b8 100644 --- a/scene/resources/visual_shader.cpp +++ b/scene/resources/visual_shader.cpp @@ -962,12 +962,13 @@ void VisualShader::remove_node(Type p_type, int p_id) { for (List::Element *E = g->connections.front(); E;) { List::Element *N = E->next(); - if (E->get().from_node == p_id || E->get().to_node == p_id) { - if (E->get().from_node == p_id) { - g->nodes[E->get().to_node].prev_connected_nodes.erase(p_id); - g->nodes[E->get().to_node].node->set_input_port_connected(E->get().to_port, false); - } else if (E->get().to_node == p_id) { - g->nodes[E->get().from_node].next_connected_nodes.erase(p_id); + const VisualShader::Connection &connection = E->get(); + if (connection.from_node == p_id || connection.to_node == p_id) { + if (connection.from_node == p_id) { + g->nodes[connection.to_node].prev_connected_nodes.erase(p_id); + g->nodes[connection.to_node].node->set_input_port_connected(connection.to_port, false); + } else if (connection.to_node == p_id) { + g->nodes[connection.from_node].next_connected_nodes.erase(p_id); } g->connections.erase(E); }