From e6a8c45fd984c320d46810e5052cbd98569113c6 Mon Sep 17 00:00:00 2001 From: Leon Schittek Date: Mon, 5 Jun 2023 20:21:07 +0200 Subject: [PATCH] Fix #108578: Crash when unlinking input sockets Fix a mistake in commit 2ce5fc4a3e that caused a crash when detaching node links from input sockets. When a link is detached from an input socket, `nodeRemLink` nulls the `link` pointer of the socket. So before the next update inputs are linked but don't have a valid `link` pointer causing the crash, when trying to access the link in `std_node_socket_draw`. The introduced check avoids the crash and is more correct since it doesn't just check one link for multi-input sockets. Pull Request: https://projects.blender.org/blender/blender/pulls/108623 --- source/blender/editors/space_node/drawnode.cc | 2 +- source/blender/editors/space_node/node_intern.hh | 1 + source/blender/editors/space_node/node_relationships.cc | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_node/drawnode.cc b/source/blender/editors/space_node/drawnode.cc index 40ba4e1b450..78860a290d4 100644 --- a/source/blender/editors/space_node/drawnode.cc +++ b/source/blender/editors/space_node/drawnode.cc @@ -1296,7 +1296,7 @@ static void std_node_socket_draw( } if ((sock->in_out == SOCK_OUT) || (sock->flag & SOCK_HIDE_VALUE) || - ((sock->flag & SOCK_IS_LINKED) && !(sock->link->is_muted()))) + ((sock->flag & SOCK_IS_LINKED) && !all_links_muted(*sock))) { node_socket_button_label(C, layout, ptr, node_ptr, text); return; diff --git a/source/blender/editors/space_node/node_intern.hh b/source/blender/editors/space_node/node_intern.hh index cb93ff37533..290d69e6f83 100644 --- a/source/blender/editors/space_node/node_intern.hh +++ b/source/blender/editors/space_node/node_intern.hh @@ -290,6 +290,7 @@ void NODE_OT_group_edit(wmOperatorType *ot); /* node_relationships.cc */ void update_multi_input_indices_for_removed_links(bNode &node); +bool all_links_muted(const bNodeSocket &socket); void NODE_OT_link(wmOperatorType *ot); void NODE_OT_link_make(wmOperatorType *ot); diff --git a/source/blender/editors/space_node/node_relationships.cc b/source/blender/editors/space_node/node_relationships.cc index b31b38f4318..893bb6ed43f 100644 --- a/source/blender/editors/space_node/node_relationships.cc +++ b/source/blender/editors/space_node/node_relationships.cc @@ -1587,7 +1587,7 @@ void NODE_OT_links_cut(wmOperatorType *ot) /** \name Mute Links Operator * \{ */ -static bool all_links_muted(const bNodeSocket &socket) +bool all_links_muted(const bNodeSocket &socket) { for (const bNodeLink *link : socket.directly_linked_links()) { if (!(link->flag & NODE_LINK_MUTED)) {