From abba67fd7976f0e67ad7a3d8815fdd7f5d1c6bea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20T=C3=B6nne?= Date: Tue, 7 Oct 2025 16:18:34 +0200 Subject: [PATCH] Fix #147283: Socket lookup by index fails when the node group is missing The link-insert operator was doing index lookup for node socket declarations based on the `bNodeSocket` index, which fails when the node group data block is missing. The safe approach to this is to use the existing declarations and look up the node socket from that. Pull Request: https://projects.blender.org/blender/blender/pulls/147528 --- source/blender/editors/space_node/node_relationships.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/space_node/node_relationships.cc b/source/blender/editors/space_node/node_relationships.cc index 9dc702d7297..707aa7d4ea0 100644 --- a/source/blender/editors/space_node/node_relationships.cc +++ b/source/blender/editors/space_node/node_relationships.cc @@ -2844,13 +2844,12 @@ bNodeSocket *get_main_socket(bNodeTree &ntree, bNode &node, eNodeSocketInOut in_ if (node_decl != nullptr) { Span socket_decls = (in_out == SOCK_IN) ? node_decl->inputs : node_decl->outputs; - int index; - LISTBASE_FOREACH_INDEX (bNodeSocket *, socket, sockets, index) { - const nodes::SocketDeclaration &socket_decl = *socket_decls[index]; - if (!socket->is_visible()) { + for (const nodes::SocketDeclaration *socket_decl : socket_decls) { + if (!socket_decl->is_default_link_socket) { continue; } - if (socket_decl.is_default_link_socket) { + bNodeSocket *socket = static_cast(BLI_findlink(sockets, socket_decl->index)); + if (socket && socket->is_visible()) { return socket; } }