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; } }