[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55717] trunk/blender/source/blender: Fix for #34756 and #34810, crashes when dropping nodes onto noodles and a related forward compatibility bug .

Lukas Toenne lukas.toenne at googlemail.com
Tue Apr 2 13:59:28 CEST 2013


Revision: 55717
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55717
Author:   lukastoenne
Date:     2013-04-02 11:59:27 +0000 (Tue, 02 Apr 2013)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/node.c
    trunk/blender/source/blender/editors/space_node/node_relationships.c

Modified: trunk/blender/source/blender/blenkernel/intern/node.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/node.c	2013-04-02 10:48:11 UTC (rev 55716)
+++ trunk/blender/source/blender/blenkernel/intern/node.c	2013-04-02 11:59:27 UTC (rev 55717)
@@ -190,7 +190,10 @@
 {
 	if (typeinfo) {
 		sock->typeinfo = typeinfo;
-	
+		
+		/* deprecated integer type */
+		sock->type = typeinfo->type;
+		
 		if (sock->default_value == NULL) {
 			/* initialize the default_value pointer used by standard socket types */
 			node_socket_init_default_value(sock);

Modified: trunk/blender/source/blender/editors/space_node/node_relationships.c
===================================================================
--- trunk/blender/source/blender/editors/space_node/node_relationships.c	2013-04-02 10:48:11 UTC (rev 55716)
+++ trunk/blender/source/blender/editors/space_node/node_relationships.c	2013-04-02 11:59:27 UTC (rev 55717)
@@ -1408,17 +1408,23 @@
 			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);
+		}
 	}
 }




More information about the Bf-blender-cvs mailing list