[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59589] trunk/blender/source/blender/ makesrna/intern/rna_nodetree.c: Fix #36584, in python inputs/ outputs of created node group not accessable by their names.

Lukas Toenne lukas.toenne at googlemail.com
Wed Aug 28 09:09:36 CEST 2013


Revision: 59589
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59589
Author:   lukastoenne
Date:     2013-08-28 07:09:36 +0000 (Wed, 28 Aug 2013)
Log Message:
-----------
Fix #36584, in python inputs/outputs of created node group not accessable by their names.
The lookupstring function for node sockets and node tree interface items was using the identifier strings of bNodeSocket. This would ensure uniqueness, but doesn't work nicely because the identifier is
not the RNA name property and differs for node groups (with regular nodes it only differs if socket names are duplicate).

Now removed the specialized callbacks, so that inputs/outputs collections simply use the name property. In cases where socket names are duplicate (e.g. math node "Value" + "Value") only the first socket
is returned, but in such cases access by index is the preferred method anyway.

Modified Paths:
--------------
    trunk/blender/source/blender/makesrna/intern/rna_nodetree.c

Modified: trunk/blender/source/blender/makesrna/intern/rna_nodetree.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_nodetree.c	2013-08-28 06:36:54 UTC (rev 59588)
+++ trunk/blender/source/blender/makesrna/intern/rna_nodetree.c	2013-08-28 07:09:36 UTC (rev 59589)
@@ -921,22 +921,6 @@
 	}
 }
 
-static int rna_NodeTree_inputs_lookupstring(PointerRNA *ptr, const char *key, PointerRNA *r_ptr)
-{
-	bNodeTree *ntree = (bNodeTree *)ptr->data;
-	bNodeSocket *sock = ntreeFindSocketInterface(ntree, SOCK_IN, key);
-	RNA_pointer_create(ptr->id.data, &RNA_NodeSocketInterface, sock, r_ptr);
-	return (sock != NULL);
-}
-
-static int rna_NodeTree_outputs_lookupstring(PointerRNA *ptr, const char *key, PointerRNA *r_ptr)
-{
-	bNodeTree *ntree = (bNodeTree *)ptr->data;
-	bNodeSocket *sock = ntreeFindSocketInterface(ntree, SOCK_OUT, key);
-	RNA_pointer_create(ptr->id.data, &RNA_NodeSocketInterface, sock, r_ptr);
-	return (sock != NULL);
-}
-
 static bNodeSocket *rna_NodeTree_inputs_new(bNodeTree *ntree, ReportList *reports, const char *type, const char *name)
 {
 	bNodeSocket *sock;
@@ -1563,22 +1547,6 @@
 	BKE_all_animdata_fix_paths_rename(NULL, "nodes", oldname, node->name);
 }
 
-static int rna_Node_inputs_lookupstring(PointerRNA *ptr, const char *key, PointerRNA *r_ptr)
-{
-	bNode *node = (bNode *)ptr->data;
-	bNodeSocket *sock = nodeFindSocket(node, SOCK_IN, key);
-	RNA_pointer_create(ptr->id.data, &RNA_NodeSocket, sock, r_ptr);
-	return (sock != NULL);
-}
-
-static int rna_Node_outputs_lookupstring(PointerRNA *ptr, const char *key, PointerRNA *r_ptr)
-{
-	bNode *node = (bNode *)ptr->data;
-	bNodeSocket *sock = nodeFindSocket(node, SOCK_OUT, key);
-	RNA_pointer_create(ptr->id.data, &RNA_NodeSocket, sock, r_ptr);
-	return (sock != NULL);
-}
-
 static bNodeSocket *rna_Node_inputs_new(ID *id, bNode *node, ReportList *reports, const char *type, const char *name, const char *identifier)
 {
 	bNodeTree *ntree = (bNodeTree *)id;
@@ -6841,16 +6809,12 @@
 	
 	prop = RNA_def_property(srna, "inputs", PROP_COLLECTION, PROP_NONE);
 	RNA_def_property_collection_sdna(prop, NULL, "inputs", NULL);
-	RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, NULL, NULL, NULL,
-	                                  "rna_Node_inputs_lookupstring", NULL);
 	RNA_def_property_struct_type(prop, "NodeSocket");
 	RNA_def_property_ui_text(prop, "Inputs", "");
 	rna_def_node_sockets_api(brna, prop, SOCK_IN);
 	
 	prop = RNA_def_property(srna, "outputs", PROP_COLLECTION, PROP_NONE);
 	RNA_def_property_collection_sdna(prop, NULL, "outputs", NULL);
-	RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, NULL, NULL, NULL,
-	                                  "rna_Node_outputs_lookupstring", NULL);
 	RNA_def_property_struct_type(prop, "NodeSocket");
 	RNA_def_property_ui_text(prop, "Outputs", "");
 	rna_def_node_sockets_api(brna, prop, SOCK_OUT);
@@ -7266,8 +7230,6 @@
 
 	prop = RNA_def_property(srna, "inputs", PROP_COLLECTION, PROP_NONE);
 	RNA_def_property_collection_sdna(prop, NULL, "inputs", NULL);
-	RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, NULL, NULL, NULL,
-	                                  "rna_NodeTree_inputs_lookupstring", NULL);
 	RNA_def_property_struct_type(prop, "NodeSocketInterface");
 	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 	RNA_def_property_ui_text(prop, "Inputs", "Node tree inputs");
@@ -7280,8 +7242,6 @@
 
 	prop = RNA_def_property(srna, "outputs", PROP_COLLECTION, PROP_NONE);
 	RNA_def_property_collection_sdna(prop, NULL, "outputs", NULL);
-	RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, NULL, NULL, NULL,
-	                                  "rna_NodeTree_outputs_lookupstring", NULL);
 	RNA_def_property_struct_type(prop, "NodeSocketInterface");
 	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 	RNA_def_property_ui_text(prop, "Outputs", "Node tree outputs");




More information about the Bf-blender-cvs mailing list