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
This commit is contained in:
@@ -2844,13 +2844,12 @@ bNodeSocket *get_main_socket(bNodeTree &ntree, bNode &node, eNodeSocketInOut in_
|
||||
if (node_decl != nullptr) {
|
||||
Span<nodes::SocketDeclaration *> 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<bNodeSocket *>(BLI_findlink(sockets, socket_decl->index));
|
||||
if (socket && socket->is_visible()) {
|
||||
return socket;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user