From 1eb611ea55cd9fdf23c8e5b712a144d291d4f0ed Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Fri, 10 Aug 2012 07:22:33 +0000 Subject: Added a poll function for the node_tree pointer node groups. This ensure that only node trees of the same type as the group node's tree can be selected for the pointer, other trees would be invalid for the node group (e.g. a Shader node group using a Compositor node tree). --- source/blender/makesrna/intern/rna_nodetree.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source/blender/makesrna') diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index eadd4f16a8a..a0e15b48e23 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -439,6 +439,15 @@ static void rna_NodeGroup_update(Main *bmain, Scene *scene, PointerRNA *ptr) node_update(bmain, scene, ntree, node); } +static int rna_NodeGroup_node_tree_poll(PointerRNA *ptr, const PointerRNA value) +{ + bNodeTree *ntree = (bNodeTree *)ptr->id.data; + bNodeTree *ngroup = (bNodeTree *)value.data; + + /* only allow node trees of the same type as the group node's tree */ + return (ngroup->type == ntree->type); +} + static void rna_Node_name_set(PointerRNA *ptr, const char *value) { bNodeTree *ntree = (bNodeTree *)ptr->id.data; @@ -1129,6 +1138,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_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Node Tree", ""); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeGroup_update"); -- cgit v1.2.3