diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-12-13 14:39:11 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-12-13 14:39:11 +0300 |
commit | 7a581f95d002d6758079256e690b9fb14bd51bc9 (patch) | |
tree | ee900b6200f25cf280b012ad37acb4b20a8820d2 /source/blender/makesrna/intern/rna_access.c | |
parent | 7bf5d9449c615120169eb290a3a8f46e53157340 (diff) |
check if a path can be created to a property before showing keyframe items in menus since they only give an error when accessed.
Diffstat (limited to 'source/blender/makesrna/intern/rna_access.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index f95e18f3722..bf77d73351c 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -1238,6 +1238,29 @@ int RNA_property_animated(PointerRNA *ptr, PropertyRNA *prop) return 0; } + +/* this function is to check if its possible to create a valid path from the ID + * its slow so dont call in a loop */ +int RNA_property_path_from_ID_check(PointerRNA *ptr, PropertyRNA *prop) +{ + char *path= RNA_path_from_ID_to_property(ptr, prop); + int ret= 0; + + if(path) { + PointerRNA id_ptr; + PointerRNA r_ptr; + PropertyRNA *r_prop; + + RNA_id_pointer_create(ptr->id.data, &id_ptr); + RNA_path_resolve(&id_ptr, path, &r_ptr, &r_prop); + ret= (prop == r_prop); + MEM_freeN(path); + } + + return ret; +} + + static void rna_property_update(bContext *C, Main *bmain, Scene *scene, PointerRNA *ptr, PropertyRNA *prop) { int is_rna = (prop->magic == RNA_MAGIC); @@ -4760,4 +4783,3 @@ int RNA_property_copy(PointerRNA *ptr, PointerRNA *fromptr, PropertyRNA *prop, i return 0; } - |