diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2016-02-09 14:44:06 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2016-02-09 14:51:07 +0300 |
commit | 337b718695c8b31dadc22438b9f1af40d225e0ad (patch) | |
tree | 976974961c40f6d764beef0a1389599998fe3496 /source/blender/makesrna/intern/rna_access.c | |
parent | ae2036e69b88abb5c65179a70e97be17655bc7d4 (diff) |
Fix T47371 - add access to 'static' enum items.
Some dynamic enums, which do not need a valid context pointer, have their 'itemf'
callback always called. This is annoying for introspection tools (like the ones generating
translations, or API documentation), because it means they never have access to all possible
options (enum items).
So now, there is also an `enum_items_static` accessor to get only statically-defined
enum items.
Note: only i18n tools take advantage of this currently, others are still to be updated.
Reviewers: campbellbarton, sergey
Differential Revision: https://developer.blender.org/D1782
Diffstat (limited to 'source/blender/makesrna/intern/rna_access.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index b1038f8e35c..e6178710389 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -1215,14 +1215,15 @@ EnumPropertyItem DummyRNA_DEFAULT_items[] = { {0, NULL, 0, NULL, NULL} }; -void RNA_property_enum_items(bContext *C, PointerRNA *ptr, PropertyRNA *prop, EnumPropertyItem **r_item, - int *r_totitem, bool *r_free) +void RNA_property_enum_items_ex( + bContext *C, PointerRNA *ptr, PropertyRNA *prop, const bool use_static, + EnumPropertyItem **r_item, int *r_totitem, bool *r_free) { EnumPropertyRNA *eprop = (EnumPropertyRNA *)rna_ensure_property(prop); *r_free = false; - if (eprop->itemf && (C != NULL || (prop->flag & PROP_ENUM_NO_CONTEXT))) { + if (!use_static && eprop->itemf && (C != NULL || (prop->flag & PROP_ENUM_NO_CONTEXT))) { EnumPropertyItem *item; if (prop->flag & PROP_ENUM_NO_CONTEXT) @@ -1250,6 +1251,12 @@ void RNA_property_enum_items(bContext *C, PointerRNA *ptr, PropertyRNA *prop, En } } +void RNA_property_enum_items( + bContext *C, PointerRNA *ptr, PropertyRNA *prop, EnumPropertyItem **r_item, int *r_totitem, bool *r_free) +{ + RNA_property_enum_items_ex(C, ptr, prop, false, r_item, r_totitem, r_free); +} + #ifdef WITH_INTERNATIONAL static void property_enum_translate(PropertyRNA *prop, EnumPropertyItem **r_item, int *r_totitem, bool *r_free) { |