diff options
author | Bastien Montagne <bastien@blender.org> | 2021-08-18 13:53:15 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2021-08-18 17:49:20 +0300 |
commit | 9bfd4ae22293caedfb8e150512cc911bfc95d35f (patch) | |
tree | 8ad80206e7134b13b8954a382b5f187426e8cc02 /source | |
parent | 04376c3bac796c9fb4bc2e33150484e357a65eab (diff) |
LibOverride: tweak resync detection code at apply phase.
This code checks whether an ID pointer property of an override does not
match its linked reference when it is expected to do so.
This is a goiod indication that a resync is needed.
Previous code would falsy detect overrides of IDs referencing themselves
as needing a resync, when this is not effectively the case.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/makesrna/intern/rna_access_compare_override.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/source/blender/makesrna/intern/rna_access_compare_override.c b/source/blender/makesrna/intern/rna_access_compare_override.c index 3912c873fd0..2c552970c82 100644 --- a/source/blender/makesrna/intern/rna_access_compare_override.c +++ b/source/blender/makesrna/intern/rna_access_compare_override.c @@ -1096,6 +1096,7 @@ static void rna_property_override_check_resync(Main *bmain, PointerRNA *ptr_item_dst, PointerRNA *ptr_item_src) { + ID *id_owner = rna_property_override_property_real_id_owner(bmain, ptr_dst, NULL, NULL); ID *id_src = rna_property_override_property_real_id_owner(bmain, ptr_item_src, NULL, NULL); ID *id_dst = rna_property_override_property_real_id_owner(bmain, ptr_item_dst, NULL, NULL); @@ -1109,9 +1110,18 @@ static void rna_property_override_check_resync(Main *bmain, * remapped to its new local override. In that case overrides and linked data * are always properly matching. */ id_src != id_dst && - /* If one of the pointers is NULL and not the other, or if linked reference ID - * of `id_src` is not `id_dst`, we are in a non-matching case. */ - (ELEM(NULL, id_src, id_dst) || id_src->override_library->reference != id_dst)) { + /* If one of the pointers is NULL and not the other, we are in a non-matching case. */ + (ELEM(NULL, id_src, id_dst) || + /* If `id_dst` is not from same lib as id_src, and linked reference ID of `id_src` is not + * `id_dst`, we are in a non-matching case. */ + (id_dst->lib != id_src->lib && id_src->override_library->reference != id_dst) || + /* If `id_dst` is from same lib as id_src, and is not same as `id_owner`, we are in a + * non-matching case. + * + * NOTE: Here we are testing if `id_owner` is referencing itself, in that case the new + * override copy generated by `BKE_lib_override_library_update` will already have its + * self-references updated to itself, instead of still pointing to its linked source. */ + (id_dst->lib == id_src->lib && id_dst != id_owner))) { ptr_dst->owner_id->tag |= LIB_TAG_LIB_OVERRIDE_NEED_RESYNC; CLOG_INFO(&LOG, 3, "Local override %s detected as needing resync", ptr_dst->owner_id->name); } |