From f93e0f1a9eefb162cf9432240b101a5d9c372910 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 10 Jul 2020 15:23:52 +0200 Subject: Refactor override code to properly deal with runtime rna properties too. The triplet static RNA / runtime RNA / custom properties is a real pain to deal with... Using the new `PropertyRNAOrID` struct helps clarifying and properly dealing with all three cases. Note that this makes override of py-defined RNA properties working (support for that will be committed next). Differential Revision: https://developer.blender.org/D8249 --- source/blender/makesrna/intern/rna_access.c | 4 +- .../makesrna/intern/rna_access_compare_override.c | 157 +++++++++------------ source/blender/makesrna/intern/rna_internal.h | 8 +- .../blender/makesrna/intern/rna_internal_types.h | 12 +- source/blender/makesrna/intern/rna_rna.c | 85 +++++------ 5 files changed, 115 insertions(+), 151 deletions(-) (limited to 'source/blender') diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index c3b417ca79d..8bf715f93c1 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -2145,9 +2145,7 @@ bool RNA_property_editable_info(PointerRNA *ptr, PropertyRNA *prop, const char * return false; } if (ID_IS_OVERRIDE_LIBRARY(id)) { - /* We need the real data property in case of IDProperty here... */ - PropertyRNA *real_prop = rna_ensure_property_realdata(&prop, ptr); - if (real_prop == NULL || !RNA_property_overridable_get(ptr, real_prop)) { + if (!RNA_property_overridable_get(ptr, prop)) { if (!(*r_info)[0]) { *r_info = N_("Can't edit this property from an override data-block"); } diff --git a/source/blender/makesrna/intern/rna_access_compare_override.c b/source/blender/makesrna/intern/rna_access_compare_override.c index 6789b8173f3..a89c8c4667d 100644 --- a/source/blender/makesrna/intern/rna_access_compare_override.c +++ b/source/blender/makesrna/intern/rna_access_compare_override.c @@ -177,11 +177,8 @@ bool RNA_property_copy( } static int rna_property_override_diff(Main *bmain, - PointerRNA *ptr_a, - PointerRNA *ptr_b, - PropertyRNA *prop, - PropertyRNA *prop_a, - PropertyRNA *prop_b, + PropertyRNAOrID *prop_a, + PropertyRNAOrID *prop_b, const char *rna_path, const size_t rna_path_len, eRNACompareMode mode, @@ -194,8 +191,12 @@ bool RNA_property_equals( { BLI_assert(ELEM(mode, RNA_EQ_STRICT, RNA_EQ_UNSET_MATCH_ANY, RNA_EQ_UNSET_MATCH_NONE)); - return (rna_property_override_diff( - bmain, ptr_a, ptr_b, prop, NULL, NULL, NULL, 0, mode, NULL, 0, NULL) == 0); + PropertyRNAOrID prop_a, prop_b; + + rna_property_rna_or_id_get(prop, ptr_a, &prop_a); + rna_property_rna_or_id_get(prop, ptr_b, &prop_b); + + return (rna_property_override_diff(bmain, &prop_a, &prop_b, NULL, 0, mode, NULL, 0, NULL) == 0); } bool RNA_struct_equals(Main *bmain, PointerRNA *ptr_a, PointerRNA *ptr_b, eRNACompareMode mode) @@ -247,11 +248,8 @@ bool RNA_struct_equals(Main *bmain, PointerRNA *ptr_a, PointerRNA *ptr_b, eRNACo * but we cannot determine an order (greater than/lesser than), we return 1. */ static int rna_property_override_diff(Main *bmain, - PointerRNA *ptr_a, - PointerRNA *ptr_b, - PropertyRNA *prop, - PropertyRNA *prop_a, - PropertyRNA *prop_b, + PropertyRNAOrID *prop_a, + PropertyRNAOrID *prop_b, const char *rna_path, const size_t rna_path_len, eRNACompareMode mode, @@ -259,47 +257,33 @@ static int rna_property_override_diff(Main *bmain, const eRNAOverrideMatch flags, eRNAOverrideMatchResult *r_report_flags) { - if (prop != NULL) { - BLI_assert(prop_a == NULL && prop_b == NULL); - prop_a = prop; - prop_b = prop; - } - - if (ELEM(NULL, prop_a, prop_b)) { - return (prop_a == prop_b) ? 0 : 1; - } + BLI_assert(!ELEM(NULL, prop_a, prop_b)); - if (!RNA_property_comparable(ptr_a, prop_a) || !RNA_property_comparable(ptr_b, prop_b)) { + if (prop_a->rnaprop->flag_override & PROPOVERRIDE_NO_COMPARISON || + prop_b->rnaprop->flag_override & PROPOVERRIDE_NO_COMPARISON) { return 0; } if (mode == RNA_EQ_UNSET_MATCH_ANY) { /* Unset properties are assumed to match anything. */ - if (!RNA_property_is_set(ptr_a, prop_a) || !RNA_property_is_set(ptr_b, prop_b)) { + if (!prop_a->is_set || !prop_b->is_set) { return 0; } } else if (mode == RNA_EQ_UNSET_MATCH_NONE) { /* Unset properties never match set properties. */ - if (RNA_property_is_set(ptr_a, prop_a) != RNA_property_is_set(ptr_b, prop_b)) { + if (prop_a->is_set != prop_b->is_set) { return 1; } } - if (prop != NULL) { - /* Ensure we get real property data, be it an actual RNA property, - * or an IDProperty in disguise. */ - prop_a = rna_ensure_property_realdata(&prop_a, ptr_a); - prop_b = rna_ensure_property_realdata(&prop_b, ptr_b); - - if (ELEM(NULL, prop_a, prop_b)) { - return (prop_a == prop_b) ? 0 : 1; - } + if (prop_a->is_idprop && ELEM(NULL, prop_a->idprop, prop_b->idprop)) { + return (prop_a->idprop == prop_b->idprop) ? 0 : 1; } /* Check if we are working with arrays. */ - const bool is_array_a = RNA_property_array_check(prop_a); - const bool is_array_b = RNA_property_array_check(prop_b); + const bool is_array_a = prop_a->is_array; + const bool is_array_b = prop_b->is_array; if (is_array_a != is_array_b) { /* Should probably never happen actually... */ @@ -308,8 +292,8 @@ static int rna_property_override_diff(Main *bmain, } /* Get the length of the array to work with. */ - const int len_a = RNA_property_array_length(ptr_a, prop_a); - const int len_b = RNA_property_array_length(ptr_b, prop_b); + const uint len_a = prop_a->array_len; + const uint len_b = prop_b->array_len; if (len_a != len_b) { /* Do not handle override in that case, @@ -324,30 +308,31 @@ static int rna_property_override_diff(Main *bmain, RNAPropOverrideDiff override_diff = NULL; /* Special case for IDProps, we use default callback then. */ - if (prop_a->magic != RNA_MAGIC) { + if (prop_a->is_idprop) { override_diff = rna_property_override_diff_default; - if (prop_b->magic == RNA_MAGIC && prop_b->override_diff != override_diff) { + if (!prop_b->is_idprop && prop_b->rnaprop->override_diff != override_diff) { override_diff = NULL; } } - else if (prop_b->magic != RNA_MAGIC) { + else if (prop_b->is_idprop) { override_diff = rna_property_override_diff_default; - if (prop_a->override_diff != override_diff) { + if (prop_a->rnaprop->override_diff != override_diff) { override_diff = NULL; } } - else if (prop_a->override_diff == prop_b->override_diff) { - override_diff = prop_a->override_diff; + else if (prop_a->rnaprop->override_diff == prop_b->rnaprop->override_diff) { + override_diff = prop_a->rnaprop->override_diff; + if (override_diff == NULL) { + override_diff = rna_property_override_diff_default; + } } if (override_diff == NULL) { #ifndef NDEBUG printf("'%s' gives unmatching or NULL RNA diff callbacks, should not happen (%d vs. %d).\n", - rna_path ? - rna_path : - (prop_a->magic != RNA_MAGIC ? ((IDProperty *)prop_a)->name : prop_a->identifier), - prop_a->magic == RNA_MAGIC, - prop_b->magic == RNA_MAGIC); + rna_path ? rna_path : prop_a->identifier, + !prop_a->is_idprop, + !prop_b->is_idprop); #endif BLI_assert(0); return 1; @@ -355,16 +340,12 @@ static int rna_property_override_diff(Main *bmain, bool override_changed = false; eRNAOverrideMatch diff_flags = flags; - if (!RNA_property_overridable_get(ptr_a, prop_a)) { + if (!RNA_property_overridable_get(&prop_a->ptr, prop_a->rawprop)) { diff_flags &= ~RNA_OVERRIDE_COMPARE_CREATE; } const int diff = override_diff(bmain, - ptr_a, - ptr_b, prop_a, prop_b, - len_a, - len_b, mode, override, rna_path, @@ -426,10 +407,13 @@ static bool rna_property_override_operation_store(Main *bmain, } else if (prop_local->override_store == prop_reference->override_store) { override_store = prop_local->override_store; + if (override_store == NULL) { + override_store = rna_property_override_store_default; + } } if (ptr_storage != NULL && prop_storage->magic == RNA_MAGIC && - prop_storage->override_store != override_store) { + !ELEM(prop_storage->override_store, NULL, override_store)) { override_store = NULL; } @@ -512,10 +496,13 @@ static bool rna_property_override_operation_apply(Main *bmain, } else if (prop_dst->override_apply == prop_src->override_apply) { override_apply = prop_dst->override_apply; + if (override_apply == NULL) { + override_apply = rna_property_override_apply_default; + } } if (ptr_storage && prop_storage->magic == RNA_MAGIC && - prop_storage->override_apply != override_apply) { + !ELEM(prop_storage->override_apply, NULL, override_apply)) { override_apply = NULL; } @@ -612,38 +599,29 @@ bool RNA_struct_override_matches(Main *bmain, for (RNA_property_collection_begin(ptr_local, iterprop, &iter); iter.valid; RNA_property_collection_next(&iter)) { - PropertyRNA *prop_local = iter.ptr.data; - PropertyRNA *prop_reference = iter.ptr.data; - - /* Ensure we get real property data, be it an actual RNA property, - * or an IDProperty in disguise. */ - prop_local = rna_ensure_property_realdata(&prop_local, ptr_local); - prop_reference = rna_ensure_property_realdata(&prop_reference, ptr_reference); - - /* IDProps (custom properties) are even more of a PITA here, we cannot use - * `rna_ensure_property_realdata()` to deal with them, we have to use the path generated from - * `prop_local` (which is valid) to access to the actual reference counterpart... */ - if (prop_local != NULL && prop_local->magic != RNA_MAGIC && prop_local == prop_reference) { - /* We could also use (lower in this code, after rna_path has been computed): - * RNA_path_resolve_property(ptr_reference, rna_path, &some_rna_ptr, &prop_reference); - * But that would be much more costly, and would also fail when ptr_reference - * is not an ID pointer itself, so we'd need to rebuild it from its owner_id, then check that - * generated some_rna_ptr and ptr_reference do point to the same data, etc. - * For now, let's try that simple access, it won't cover all cases but should handle fine - * most basic custom properties situations. */ - prop_reference = (PropertyRNA *)rna_idproperty_find(ptr_reference, - ((IDProperty *)prop_local)->name); - } + PropertyRNA *rawprop = iter.ptr.data; + + PropertyRNAOrID prop_local; + PropertyRNAOrID prop_reference; - if (ELEM(NULL, prop_local, prop_reference)) { + rna_property_rna_or_id_get(rawprop, ptr_local, &prop_local); + rna_property_rna_or_id_get(rawprop, ptr_reference, &prop_reference); + + BLI_assert(prop_local.rnaprop != NULL); + BLI_assert(prop_local.rnaprop == prop_reference.rnaprop); + BLI_assert(prop_local.is_idprop == prop_reference.is_idprop); + + if ((prop_local.is_idprop && prop_local.idprop == NULL) || + (prop_reference.is_idprop && prop_reference.idprop == NULL)) { continue; } - if (ignore_non_overridable && !RNA_property_overridable_get(ptr_local, prop_local)) { + if (ignore_non_overridable && !RNA_property_overridable_get(&prop_local.ptr, rawprop)) { continue; } - if (RNA_property_override_flag(prop_local) & PROPOVERRIDE_IGNORE) { + if (!prop_local.is_idprop && + RNA_property_override_flag(prop_local.rnaprop) & PROPOVERRIDE_IGNORE) { continue; } @@ -665,11 +643,11 @@ bool RNA_struct_override_matches(Main *bmain, if (root_path) { BLI_assert(strlen(root_path) == root_path_len); - const char *prop_name = RNA_property_identifier(prop_local); + const char *prop_name = prop_local.identifier; const size_t prop_name_len = strlen(prop_name); /* Inlined building, much much more efficient. */ - if (prop_local->magic == RNA_MAGIC) { + if (!prop_local.is_idprop) { rna_path_len = root_path_len + 1 + prop_name_len; if (rna_path_len >= RNA_PATH_BUFFSIZE) { rna_path = MEM_mallocN(rna_path_len + 1, __func__); @@ -697,7 +675,7 @@ bool RNA_struct_override_matches(Main *bmain, } else { /* This is rather slow, but is not much called, so not really worth optimizing. */ - rna_path = RNA_path_from_ID_to_property(ptr_local, prop_local); + rna_path = RNA_path_from_ID_to_property(ptr_local, rawprop); if (rna_path != NULL) { rna_path_len = strlen(rna_path); } @@ -726,11 +704,8 @@ bool RNA_struct_override_matches(Main *bmain, eRNAOverrideMatchResult report_flags = 0; const int diff = rna_property_override_diff(bmain, - ptr_local, - ptr_reference, - NULL, - prop_local, - prop_reference, + &prop_local, + &prop_reference, rna_path, rna_path_len, RNA_EQ_STRICT, @@ -764,7 +739,7 @@ bool RNA_struct_override_matches(Main *bmain, /* We are allowed to restore to reference's values. */ if (ELEM(NULL, op, opop) || opop->operation == IDOVERRIDE_LIBRARY_OP_NOOP) { /* We should restore that property to its reference value */ - if (RNA_property_editable(ptr_local, prop_local)) { + if (RNA_property_editable(ptr_local, rawprop)) { IDOverrideLibraryPropertyOperation opop_tmp = { .operation = IDOVERRIDE_LIBRARY_OP_REPLACE, .subitem_reference_index = -1, @@ -774,8 +749,8 @@ bool RNA_struct_override_matches(Main *bmain, ptr_local, ptr_reference, NULL, - prop_local, - prop_reference, + rawprop, + rawprop, NULL, NULL, NULL, diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 0783addd78b..8e6a360f2c9 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -489,12 +489,8 @@ struct PropertyRNA *rna_ensure_property_realdata(struct PropertyRNA **prop, * Not obvious though, those are fairly more complicated than basic SDNA access. */ int rna_property_override_diff_default(struct Main *bmain, - struct PointerRNA *ptr_a, - struct PointerRNA *ptr_b, - struct PropertyRNA *prop_a, - struct PropertyRNA *prop_b, - const int len_a, - const int len_b, + struct PropertyRNAOrID *prop_a, + struct PropertyRNAOrID *prop_b, const int mode, struct IDOverrideLibrary *override, const char *rna_path, diff --git a/source/blender/makesrna/intern/rna_internal_types.h b/source/blender/makesrna/intern/rna_internal_types.h index 6336be25ac3..20c8743f768 100644 --- a/source/blender/makesrna/intern/rna_internal_types.h +++ b/source/blender/makesrna/intern/rna_internal_types.h @@ -195,23 +195,17 @@ typedef struct PropertyRNAOrID { } PropertyRNAOrID; /** - * If \a override is NULL, merely do comparison between prop_a from ptr_a and prop_b from ptr_b, + * If \a override is NULL, merely do comparison between prop_a and prop_b, * following comparison mode given. * If \a override and \a rna_path are not NULL, it will add a new override operation for * overridable properties that differ and have not yet been overridden * (and set accordingly \a r_override_changed if given). * - * \note Given PropertyRNA are final (in case of IDProps...). - * \note In non-array cases, \a len values are 0. * \note \a override, \a rna_path and \a r_override_changed may be NULL pointers. */ typedef int (*RNAPropOverrideDiff)(struct Main *bmain, - struct PointerRNA *ptr_a, - struct PointerRNA *ptr_b, - struct PropertyRNA *prop_a, - struct PropertyRNA *prop_b, - const int len_a, - const int len_b, + struct PropertyRNAOrID *prop_a, + struct PropertyRNAOrID *prop_b, const int mode, struct IDOverrideLibrary *override, const char *rna_path, diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index 623b5864f5b..39949538726 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -1431,12 +1431,8 @@ static int rna_property_override_diff_propptr(Main *bmain, RNA_property_##_typename##_set((_ptr), (_prop), (_value))) int rna_property_override_diff_default(Main *bmain, - PointerRNA *ptr_a, - PointerRNA *ptr_b, - PropertyRNA *prop_a, - PropertyRNA *prop_b, - const int len_a, - const int len_b, + PropertyRNAOrID *prop_a, + PropertyRNAOrID *prop_b, const int mode, IDOverrideLibrary *override, const char *rna_path, @@ -1444,6 +1440,13 @@ int rna_property_override_diff_default(Main *bmain, const int flags, bool *r_override_changed) { + PointerRNA *ptr_a = &prop_a->ptr; + PointerRNA *ptr_b = &prop_b->ptr; + PropertyRNA *rawprop_a = prop_a->rawprop; + PropertyRNA *rawprop_b = prop_b->rawprop; + const uint len_a = prop_a->array_len; + const uint len_b = prop_b->array_len; + BLI_assert(len_a == len_b); /* Note: at this point, we are sure that when len_a is zero, @@ -1452,7 +1455,16 @@ int rna_property_override_diff_default(Main *bmain, const bool do_create = override != NULL && (flags & RNA_OVERRIDE_COMPARE_CREATE) != 0 && rna_path != NULL; - switch (RNA_property_type(prop_a)) { + const bool no_ownership = (prop_a->rnaprop->flag & PROP_PTR_NO_OWNERSHIP) != 0; + const bool no_prop_name = (prop_a->rnaprop->flag_override & PROPOVERRIDE_NO_PROP_NAME) != 0; + + /* Note: we assume we only insert in ptr_a (i.e. we can only get new items in ptr_a), + * and that we never remove anything. */ + const bool use_collection_insertion = (prop_a->rnaprop->flag_override & + PROPOVERRIDE_LIBRARY_INSERTION) && + do_create; + + switch (RNA_property_type(prop_a->rnaprop)) { case PROP_BOOLEAN: { if (len_a) { bool array_stack_a[RNA_STACK_ARRAY], array_stack_b[RNA_STACK_ARRAY]; @@ -1463,8 +1475,8 @@ int rna_property_override_diff_default(Main *bmain, array_b = (len_b > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(bool) * len_b, "RNA equals") : array_stack_b; - RNA_property_boolean_get_array(ptr_a, prop_a, array_a); - RNA_property_boolean_get_array(ptr_b, prop_b, array_b); + RNA_property_boolean_get_array(ptr_a, rawprop_a, array_a); + RNA_property_boolean_get_array(ptr_b, rawprop_b, array_b); const int comp = memcmp(array_a, array_b, sizeof(bool) * len_a); @@ -1496,8 +1508,8 @@ int rna_property_override_diff_default(Main *bmain, return comp; } else { - const bool value_a = RNA_property_boolean_get(ptr_a, prop_a); - const bool value_b = RNA_property_boolean_get(ptr_b, prop_b); + const bool value_a = RNA_property_boolean_get(ptr_a, rawprop_a); + const bool value_b = RNA_property_boolean_get(ptr_b, rawprop_b); const int comp = (value_a < value_b) ? -1 : (value_a > value_b) ? 1 : 0; if (do_create && comp != 0) { @@ -1528,8 +1540,8 @@ int rna_property_override_diff_default(Main *bmain, array_b = (len_b > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(int) * len_b, "RNA equals") : array_stack_b; - RNA_property_int_get_array(ptr_a, prop_a, array_a); - RNA_property_int_get_array(ptr_b, prop_b, array_b); + RNA_property_int_get_array(ptr_a, rawprop_a, array_a); + RNA_property_int_get_array(ptr_b, rawprop_b, array_b); const int comp = memcmp(array_a, array_b, sizeof(int) * len_a); @@ -1561,8 +1573,8 @@ int rna_property_override_diff_default(Main *bmain, return comp; } else { - const int value_a = RNA_property_int_get(ptr_a, prop_a); - const int value_b = RNA_property_int_get(ptr_b, prop_b); + const int value_a = RNA_property_int_get(ptr_a, rawprop_a); + const int value_b = RNA_property_int_get(ptr_b, rawprop_b); const int comp = (value_a < value_b) ? -1 : (value_a > value_b) ? 1 : 0; if (do_create && comp != 0) { @@ -1593,8 +1605,8 @@ int rna_property_override_diff_default(Main *bmain, array_b = (len_b > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(float) * len_b, "RNA equals") : array_stack_b; - RNA_property_float_get_array(ptr_a, prop_a, array_a); - RNA_property_float_get_array(ptr_b, prop_b, array_b); + RNA_property_float_get_array(ptr_a, rawprop_a, array_a); + RNA_property_float_get_array(ptr_b, rawprop_b, array_b); const int comp = memcmp(array_a, array_b, sizeof(float) * len_a); @@ -1626,8 +1638,8 @@ int rna_property_override_diff_default(Main *bmain, return comp; } else { - const float value_a = RNA_property_float_get(ptr_a, prop_a); - const float value_b = RNA_property_float_get(ptr_b, prop_b); + const float value_a = RNA_property_float_get(ptr_a, rawprop_a); + const float value_b = RNA_property_float_get(ptr_b, rawprop_b); const int comp = (value_a < value_b) ? -1 : (value_a > value_b) ? 1 : 0; if (do_create && comp != 0) { @@ -1649,8 +1661,8 @@ int rna_property_override_diff_default(Main *bmain, } case PROP_ENUM: { - const int value_a = RNA_property_enum_get(ptr_a, prop_a); - const int value_b = RNA_property_enum_get(ptr_b, prop_b); + const int value_a = RNA_property_enum_get(ptr_a, rawprop_a); + const int value_b = RNA_property_enum_get(ptr_b, rawprop_b); const int comp = value_a != value_b; if (do_create && comp != 0) { @@ -1674,9 +1686,9 @@ int rna_property_override_diff_default(Main *bmain, char fixed_a[4096], fixed_b[4096]; int len_str_a, len_str_b; char *value_a = RNA_property_string_get_alloc( - ptr_a, prop_a, fixed_a, sizeof(fixed_a), &len_str_a); + ptr_a, rawprop_a, fixed_a, sizeof(fixed_a), &len_str_a); char *value_b = RNA_property_string_get_alloc( - ptr_b, prop_b, fixed_b, sizeof(fixed_b), &len_str_b); + ptr_b, rawprop_b, fixed_b, sizeof(fixed_b), &len_str_b); /* TODO we could do a check on length too, * but then we would not have a 'real' string comparison... * Maybe behind a eRNAOverrideMatch flag? */ @@ -1712,16 +1724,13 @@ int rna_property_override_diff_default(Main *bmain, } case PROP_POINTER: { - if (STREQ(RNA_property_identifier(prop_a), "rna_type")) { + if (STREQ(prop_a->identifier, "rna_type")) { /* Dummy 'pass' answer, this is a meta-data and must be ignored... */ return 0; } else { - PointerRNA propptr_a = RNA_property_pointer_get(ptr_a, prop_a); - PointerRNA propptr_b = RNA_property_pointer_get(ptr_b, prop_b); - const bool no_ownership = (RNA_property_flag(prop_a) & PROP_PTR_NO_OWNERSHIP) != 0; - const bool no_prop_name = (RNA_property_override_flag(prop_a) & - PROPOVERRIDE_NO_PROP_NAME) != 0; + PointerRNA propptr_a = RNA_property_pointer_get(ptr_a, rawprop_a); + PointerRNA propptr_b = RNA_property_pointer_get(ptr_b, rawprop_b); return rna_property_override_diff_propptr(bmain, &propptr_a, &propptr_b, @@ -1742,14 +1751,6 @@ int rna_property_override_diff_default(Main *bmain, } case PROP_COLLECTION: { - /* Note: we assume we only insert in ptr_a (i.e. we can only get new items in ptr_a), - * and that we never remove anything. */ - const bool use_insertion = (RNA_property_override_flag(prop_a) & - PROPOVERRIDE_LIBRARY_INSERTION) && - do_create; - const bool no_ownership = (RNA_property_flag(prop_a) & PROP_PTR_NO_OWNERSHIP) != 0; - const bool no_prop_name = (RNA_property_override_flag(prop_a) & PROPOVERRIDE_NO_PROP_NAME) != - 0; bool equals = true; bool abort = false; bool is_first_insert = true; @@ -1757,8 +1758,8 @@ int rna_property_override_diff_default(Main *bmain, int idx_b = 0; CollectionPropertyIterator iter_a, iter_b; - RNA_property_collection_begin(ptr_a, prop_a, &iter_a); - RNA_property_collection_begin(ptr_b, prop_b, &iter_b); + RNA_property_collection_begin(ptr_a, rawprop_a, &iter_a); + RNA_property_collection_begin(ptr_b, rawprop_b, &iter_b); char buff_a[4096]; char buff_prev_a[4096] = {0}; @@ -1773,7 +1774,7 @@ int rna_property_override_diff_default(Main *bmain, do { bool is_id = false, is_null = false, is_type_diff = false; - is_valid_for_insertion = use_insertion; + is_valid_for_insertion = use_collection_insertion; /* If false, it means that the whole data itself is different, * so no point in going inside of it at all! */ @@ -1846,7 +1847,7 @@ int rna_property_override_diff_default(Main *bmain, /* Collections do not support replacement of their data (except for collections of ID * pointers), since they do not support removing, only in *some* cases, insertion. We * also assume then that _a data is the one where things are inserted. */ - if (is_valid_for_insertion && use_insertion) { + if (is_valid_for_insertion && use_collection_insertion) { bool created; IDOverrideLibraryProperty *op = BKE_lib_override_library_property_get( override, rna_path, &created); @@ -1930,7 +1931,7 @@ int rna_property_override_diff_default(Main *bmain, break; } - if (!(use_insertion && !(is_id || is_valid_for_diffing))) { + if (!(use_collection_insertion && !(is_id || is_valid_for_diffing))) { break; } -- cgit v1.2.3