[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [56593] trunk/blender/source/blender/ makesrna/intern/rna_nodetree.c: 2 fixes for node group node_tree pointer property: Make sure the nodeGroupPoll function (which checks for recursion) is used both in the poll callback as well as the actual pointer assignment (set).

Lukas Toenne lukas.toenne at googlemail.com
Wed May 8 17:41:01 CEST 2013


Revision: 56593
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56593
Author:   lukastoenne
Date:     2013-05-08 15:41:01 +0000 (Wed, 08 May 2013)
Log Message:
-----------
2 fixes for node group node_tree pointer property: Make sure the nodeGroupPoll function (which checks for recursion) is used both in the poll callback as well as the actual pointer assignment (set). The poll callback doesn't seem to be used when directly setting the node_tree pointer from the API, so to make sure no dangerous recursion situation can happen this needs a second check.

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-05-08 15:40:58 UTC (rev 56592)
+++ trunk/blender/source/blender/makesrna/intern/rna_nodetree.c	2013-05-08 15:41:01 UTC (rev 56593)
@@ -2364,13 +2364,26 @@
 	ED_node_tag_update_nodetree(bmain, ntree);
 }
 
+static void rna_NodeGroup_node_tree_set(PointerRNA *ptr, const PointerRNA value)
+{
+	bNodeTree *ntree = ptr->id.data;
+	bNode *node = ptr->data;
+	bNodeTree *ngroup = value.data;
+	
+	if (nodeGroupPoll(ntree, ngroup))
+		node->id = &ngroup->id;
+}
+
 static int rna_NodeGroup_node_tree_poll(PointerRNA *ptr, const PointerRNA value)
 {
-	bNodeTree *ntree = (bNodeTree *)ptr->id.data;
-	bNodeTree *ngroup = (bNodeTree *)value.data;
+	bNodeTree *ntree = ptr->id.data;
+	bNodeTree *ngroup = value.data;
 	
 	/* only allow node trees of the same type as the group node's tree */
-	return (ngroup->type == ntree->type);
+	if (ngroup->type != ntree->type)
+		return false;
+	
+	return nodeGroupPoll(ntree, ngroup);
 }
 
 
@@ -2838,7 +2851,7 @@
 	prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE);
 	RNA_def_property_pointer_sdna(prop, NULL, "id");
 	RNA_def_property_struct_type(prop, "NodeTree");
-	RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_NodeGroup_node_tree_poll");
+	RNA_def_property_pointer_funcs(prop, NULL, "rna_NodeGroup_node_tree_set", NULL, "rna_NodeGroup_node_tree_poll");
 	RNA_def_property_flag(prop, PROP_EDITABLE);
 	RNA_def_property_ui_text(prop, "Node Tree", "");
 	RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeGroup_update");




More information about the Bf-blender-cvs mailing list