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:
authorCampbell Barton <ideasman42@gmail.com>2021-04-16 08:04:37 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-04-16 08:04:37 +0300
commit43b08d05786f83797d04e5d0f777ae9b888807f9 (patch)
tree71367932597d02756dc9318fe98acb7547d34961 /source/blender/makesrna/intern/rna_access.c
parentdc8a43c8755a5e880ff40765f878bf002a38096a (diff)
RNA: add STRUCT_NO_CONTEXT_WITHOUT_OWNER_ID flag
This flag is needed so PointerRNA structs that aren't part of the current context can access enum values without inspecting the context. This is needed for keymap access, so the keymap UI and keymap export doesn't depend on the current context.
Diffstat (limited to 'source/blender/makesrna/intern/rna_access.c')
-rw-r--r--source/blender/makesrna/intern/rna_access.c100
1 files changed, 50 insertions, 50 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index f94dc38ddfe..9b57096ec19 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -1623,35 +1623,35 @@ void RNA_property_enum_items_ex(bContext *C,
*r_free = false;
- if (!use_static && eprop->item_fn && (C != NULL || (prop->flag & PROP_ENUM_NO_CONTEXT))) {
- const EnumPropertyItem *item;
+ if (!use_static && (eprop->item_fn != NULL)) {
+ const bool no_context = (prop->flag & PROP_ENUM_NO_CONTEXT) ||
+ ((ptr->type->flag & STRUCT_NO_CONTEXT_WITHOUT_OWNER_ID) &&
+ (ptr->owner_id == NULL));
+ if (C != NULL || no_context) {
+ const EnumPropertyItem *item;
- if (prop->flag & PROP_ENUM_NO_CONTEXT) {
- item = eprop->item_fn(NULL, ptr, prop, r_free);
- }
- else {
- item = eprop->item_fn(C, ptr, prop, r_free);
- }
+ item = eprop->item_fn(no_context ? NULL : C, ptr, prop, r_free);
- /* any callbacks returning NULL should be fixed */
- BLI_assert(item != NULL);
+ /* any callbacks returning NULL should be fixed */
+ BLI_assert(item != NULL);
- if (r_totitem) {
- int tot;
- for (tot = 0; item[tot].identifier; tot++) {
- /* pass */
+ if (r_totitem) {
+ int tot;
+ for (tot = 0; item[tot].identifier; tot++) {
+ /* pass */
+ }
+ *r_totitem = tot;
}
- *r_totitem = tot;
- }
- *r_item = item;
- }
- else {
- *r_item = eprop->item;
- if (r_totitem) {
- *r_totitem = eprop->totitem;
+ *r_item = item;
+ return;
}
}
+
+ *r_item = eprop->item;
+ if (r_totitem) {
+ *r_totitem = eprop->totitem;
+ }
}
void RNA_property_enum_items(bContext *C,
@@ -1753,42 +1753,42 @@ void RNA_property_enum_items_gettexted_all(bContext *C,
*r_totitem = eprop->totitem;
}
- if (eprop->item_fn && (C != NULL || (prop->flag & PROP_ENUM_NO_CONTEXT))) {
- const EnumPropertyItem *item;
- int i;
- bool free = false;
+ if (eprop->item_fn != NULL) {
+ const bool no_context = (prop->flag & PROP_ENUM_NO_CONTEXT) ||
+ ((ptr->type->flag & STRUCT_NO_CONTEXT_WITHOUT_OWNER_ID) &&
+ (ptr->owner_id == NULL));
+ if (C != NULL || no_context) {
+ const EnumPropertyItem *item;
+ int i;
+ bool free = false;
- if (prop->flag & PROP_ENUM_NO_CONTEXT) {
- item = eprop->item_fn(NULL, ptr, prop, &free);
- }
- else {
- item = eprop->item_fn(C, ptr, prop, &free);
- }
+ item = eprop->item_fn(no_context ? NULL : NULL, ptr, prop, &free);
- /* any callbacks returning NULL should be fixed */
- BLI_assert(item != NULL);
+ /* any callbacks returning NULL should be fixed */
+ BLI_assert(item != NULL);
- for (i = 0; i < eprop->totitem; i++) {
- bool exists = false;
- int i_fixed;
+ for (i = 0; i < eprop->totitem; i++) {
+ bool exists = false;
+ int i_fixed;
- /* Items that do not exist on list are returned,
- * but have their names/identifiers NULL'ed out. */
- for (i_fixed = 0; item[i_fixed].identifier; i_fixed++) {
- if (STREQ(item[i_fixed].identifier, item_array[i].identifier)) {
- exists = true;
- break;
+ /* Items that do not exist on list are returned,
+ * but have their names/identifiers NULL'ed out. */
+ for (i_fixed = 0; item[i_fixed].identifier; i_fixed++) {
+ if (STREQ(item[i_fixed].identifier, item_array[i].identifier)) {
+ exists = true;
+ break;
+ }
}
- }
- if (!exists) {
- item_array[i].name = NULL;
- item_array[i].identifier = "";
+ if (!exists) {
+ item_array[i].name = NULL;
+ item_array[i].identifier = "";
+ }
}
- }
- if (free) {
- MEM_freeN((void *)item);
+ if (free) {
+ MEM_freeN((void *)item);
+ }
}
}