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-05-08 19:41:01 +0400
committerLukas Toenne <lukas.toenne@googlemail.com>2013-05-08 19:41:01 +0400
commit8542d97f73f99b1fad24f51a94bf08d44d4879d1 (patch)
treed59323f2635357d8bfb68724924487db1c7d56dd
parent3234f7e497d23a546a8fea1ad63886b99a17d4aa (diff)
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.
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 3a6cb60d18b..7bee0565c93 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -2364,13 +2364,26 @@ static void rna_NodeGroup_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *
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 @@ static void def_group(StructRNA *srna)
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");