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:
authorBastien Montagne <bastien@blender.org>2020-12-28 19:37:16 +0300
committerBastien Montagne <bastien@blender.org>2020-12-28 19:40:27 +0300
commit7f3601e70dd094b6f9162bb03a8a3440d50de47e (patch)
treec08999fdb802fcbd1eeb9d8411d7c03f54930736 /source/blender/makesrna/intern/rna_access.c
parentad63d2f60e240af9710492f0c1a3b008ce0bf8e6 (diff)
Cleanup/refactor `rna_idp_path` code.
Factorize common processes and checks, early `continue` in invalid cases, etc.
Diffstat (limited to 'source/blender/makesrna/intern/rna_access.c')
-rw-r--r--source/blender/makesrna/intern/rna_access.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 0b7ebb17d87..9411acaef64 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -5696,8 +5696,7 @@ static char *rna_idp_path(PointerRNA *ptr,
BLI_assert(haystack->type == IDP_GROUP);
link.up = parent_link;
- /* always set both name and index,
- * else a stale value might get used */
+ /* Always set both name and index, else a stale value might get used. */
link.name = NULL;
link.index = -1;
@@ -5708,19 +5707,28 @@ static char *rna_idp_path(PointerRNA *ptr,
path = rna_idp_path_create(&link);
break;
}
+
+ /* Early out in case the IDProperty type cannot contain RNA properties. */
+ if (!ELEM(iter->type, IDP_GROUP, IDP_IDPARRAY)) {
+ continue;
+ }
+
+ /* Ensure this is RNA. */
+ /* NOTE: `iter` might be a fully user-defined IDProperty (a.k.a. custom data), which name
+ * collides with an actual fully static RNA property of the same struct (which would then not
+ * be flagged with `PROP_IDPROPERTY`).
+ *
+ * That case must be ignored here, we only want to deal with runtime RNA properties stored in
+ * IDProps.
+ *
+ * See T84091. */
+ PropertyRNA *prop = RNA_struct_find_property(ptr, iter->name);
+ if (prop == NULL || (prop->flag & PROP_IDPROPERTY) == 0) {
+ continue;
+ }
+
if (iter->type == IDP_GROUP) {
- /* Ensure this is RNA. */
- PropertyRNA *prop = RNA_struct_find_property(ptr, iter->name);
-
- /* NOTE: `iter` might be a fully user-defined IDProperty (a.k.a. custom data), which name
- * collides with an actual fully static RNA property of the same struct (which would then not
- * be flagged with `PROP_IDPROPERTY`).
- *
- * That case must be ignored here, we only want to deal with runtime RNA properties stored in
- * IDProps here.
- *
- * See T84091. */
- if (prop != NULL && prop->type == PROP_POINTER && (prop->flag & PROP_IDPROPERTY) != 0) {
+ if (prop->type == PROP_POINTER) {
PointerRNA child_ptr = RNA_property_pointer_get(ptr, prop);
BLI_assert(child_ptr.type != NULL);
link.name = iter->name;
@@ -5731,9 +5739,7 @@ static char *rna_idp_path(PointerRNA *ptr,
}
}
else if (iter->type == IDP_IDPARRAY) {
- PropertyRNA *prop = RNA_struct_find_property(ptr, iter->name);
- /* See comment above in `IDP_GROUP` case, same applies here. */
- if (prop != NULL && prop->type == PROP_COLLECTION && (prop->flag & PROP_IDPROPERTY) != 0) {
+ if (prop->type == PROP_COLLECTION) {
IDProperty *array = IDP_IDPArray(iter);
if (needle >= array && needle < (iter->len + array)) { /* found! */
link.name = iter->name;