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).

This commit is contained in:
Lukas Toenne
2012-08-10 07:22:33 +00:00
parent 32a8d7cbdf
commit 1eb611ea55

View File

@@ -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");