[Bf-blender-cvs] [cf5cada6b23] master: Nodes: fix crash after undo after recent multi-input-socket changes

Jacques Lucke noreply at git.blender.org
Mon Mar 15 15:42:50 CET 2021


Commit: cf5cada6b23d5b3670c1d321b2a566c5571941c0
Author: Jacques Lucke
Date:   Mon Mar 15 15:41:41 2021 +0100
Branches: master
https://developer.blender.org/rBcf5cada6b23d5b3670c1d321b2a566c5571941c0

Nodes: fix crash after undo after recent multi-input-socket changes

The issue is that the `last_node_hovered_while_dragging_a_link` pointer is invalidated on undo.
The pointer does not have to be on the space runtime data, because it only needs to exist
as long as the operator is running.

Differential Revision: https://developer.blender.org/D10726

===================================================================

M	source/blender/editors/space_node/node_intern.h
M	source/blender/editors/space_node/node_relationships.c

===================================================================

diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h
index 241cbee00f0..bf27ab18bd4 100644
--- a/source/blender/editors/space_node/node_intern.h
+++ b/source/blender/editors/space_node/node_intern.h
@@ -60,6 +60,8 @@ typedef struct bNodeLinkDrag {
 
   /** Temporarily stores the last picked link from multi input socket operator. */
   struct bNodeLink *last_picked_multi_input_socket_link;
+
+  struct bNode *last_node_hovered_while_dragging_a_link;
 } bNodeLinkDrag;
 
 typedef struct SpaceNode_Runtime {
@@ -77,7 +79,6 @@ typedef struct SpaceNode_Runtime {
   /* XXX hack for translate_attach op-macros to pass data from transform op to insert_offset op */
   /** Temporary data for node insert offset (in UI called Auto-offset). */
   struct NodeInsertOfsData *iofsd;
-  struct bNode *last_node_hovered_while_dragging_a_link;
 } SpaceNode_Runtime;
 
 /* space_node.c */
diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c
index 9293494a16a..ee07ec7a55c 100644
--- a/source/blender/editors/space_node/node_relationships.c
+++ b/source/blender/editors/space_node/node_relationships.c
@@ -902,7 +902,7 @@ static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2])
         /* attach links to the socket */
         link->tonode = tnode;
         link->tosock = tsock;
-        snode->runtime->last_node_hovered_while_dragging_a_link = tnode;
+        nldrag->last_node_hovered_while_dragging_a_link = tnode;
         if (existing_link_connected_to_fromsock) {
           link->multi_input_socket_index =
               existing_link_connected_to_fromsock->multi_input_socket_index;
@@ -914,9 +914,9 @@ static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2])
     else {
       LISTBASE_FOREACH (LinkData *, linkdata, &nldrag->links) {
         bNodeLink *link = linkdata->data;
-        if (snode->runtime->last_node_hovered_while_dragging_a_link) {
+        if (nldrag->last_node_hovered_while_dragging_a_link) {
           sort_multi_input_socket_links(
-              snode, snode->runtime->last_node_hovered_while_dragging_a_link, NULL, cursor);
+              snode, nldrag->last_node_hovered_while_dragging_a_link, NULL, cursor);
         }
         link->tonode = NULL;
         link->tosock = NULL;



More information about the Bf-blender-cvs mailing list