Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Toenne <lukas.toenne@googlemail.com>2013-04-02 15:59:27 +0400
committerLukas Toenne <lukas.toenne@googlemail.com>2013-04-02 15:59:27 +0400
commit8abfaf880de1748988f0a10c56f726cc6761e612 (patch)
treeafe24f04a1540222e2b831cf24ce04e715909bc6 /source/blender/editors/space_node/node_relationships.c
parent37bf7dd98a494c1dd80459aa017bb796f699261b (diff)
Fix for #34756 and #34810, crashes when dropping nodes onto noodles and a related forward compatibility bug.
Added a sanity check to the ED_node_link_insert function to ensure it exits gracefully if no suitable sockets can be found. This was the problem with custom pynodes, which don't define the 'type' DNA of old sockets. The operator will have to be generalized for future nodes, but for now just not crashing seems good enough. Script node crashes in #34810 were caused by uninitialized 'type' integer as well. This is now done in the set_typeinfo function for sockets (like for trees and nodes too), to avoid any potential remaining issues of this kind. Note that new files need to be loaded and saved again once to be forward compatible again.
Diffstat (limited to 'source/blender/editors/space_node/node_relationships.c')
-rw-r--r--source/blender/editors/space_node/node_relationships.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c
index 8ff964aa932..b552aff27f9 100644
--- a/source/blender/editors/space_node/node_relationships.c
+++ b/source/blender/editors/space_node/node_relationships.c
@@ -1408,17 +1408,23 @@ void ED_node_link_insert(ScrArea *sa)
break;
if (link) {
- node = link->tonode;
- sockto = link->tosock;
-
- link->tonode = select;
- link->tosock = socket_best_match(&select->inputs);
- node_remove_extra_links(snode, link->tosock, link);
- link->flag &= ~NODE_LINKFLAG_HILITE;
-
- nodeAddLink(snode->edittree, select, socket_best_match(&select->outputs), node, sockto);
- ntreeUpdateTree(snode->edittree); /* needed for pointers */
- snode_update(snode, select);
- ED_node_tag_update_id(snode->id);
+ bNodeSocket *best_input = socket_best_match(&select->inputs);
+ bNodeSocket *best_output = socket_best_match(&select->outputs);
+
+ if (best_input && best_output) {
+ node = link->tonode;
+ sockto = link->tosock;
+
+ link->tonode = select;
+ link->tosock = best_input;
+ node_remove_extra_links(snode, link->tosock, link);
+ link->flag &= ~NODE_LINKFLAG_HILITE;
+
+ nodeAddLink(snode->edittree, select, best_output, node, sockto);
+
+ ntreeUpdateTree(snode->edittree); /* needed for pointers */
+ snode_update(snode, select);
+ ED_node_tag_update_id(snode->id);
+ }
}
}