From 02bc43d08e1d9fa67aea6d54fa8cb3bb8e3bae43 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Fri, 17 Nov 2023 23:14:58 +0100 Subject: [PATCH] Fix: versioning code results in duplicate node links This issue was caused by having some hidden links and the changes in 8149678d5e1d to `version_geometry_nodes_replace_transfer_attribute_node`. --- .../blenloader/intern/versioning_common.cc | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/source/blender/blenloader/intern/versioning_common.cc b/source/blender/blenloader/intern/versioning_common.cc index 08a370d5c3a..3c7375d0a57 100644 --- a/source/blender/blenloader/intern/versioning_common.cc +++ b/source/blender/blenloader/intern/versioning_common.cc @@ -284,20 +284,24 @@ void node_tree_relink_with_socket_id_map(bNodeTree &ntree, LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &ntree.links) { if (link->tonode == &old_node) { bNodeSocket *old_socket = link->tosock; - if (const std::string *new_identifier = map.lookup_ptr_as(old_socket->identifier)) { - bNodeSocket *new_socket = nodeFindSocket(&new_node, SOCK_IN, new_identifier->c_str()); - link->tonode = &new_node; - link->tosock = new_socket; - old_socket->link = nullptr; + if (old_socket->is_available()) { + if (const std::string *new_identifier = map.lookup_ptr_as(old_socket->identifier)) { + bNodeSocket *new_socket = nodeFindSocket(&new_node, SOCK_IN, new_identifier->c_str()); + link->tonode = &new_node; + link->tosock = new_socket; + old_socket->link = nullptr; + } } } if (link->fromnode == &old_node) { bNodeSocket *old_socket = link->fromsock; - if (const std::string *new_identifier = map.lookup_ptr_as(old_socket->identifier)) { - bNodeSocket *new_socket = nodeFindSocket(&new_node, SOCK_OUT, new_identifier->c_str()); - link->fromnode = &new_node; - link->fromsock = new_socket; - old_socket->link = nullptr; + if (old_socket->is_available()) { + if (const std::string *new_identifier = map.lookup_ptr_as(old_socket->identifier)) { + bNodeSocket *new_socket = nodeFindSocket(&new_node, SOCK_OUT, new_identifier->c_str()); + link->fromnode = &new_node; + link->fromsock = new_socket; + old_socket->link = nullptr; + } } } }