[Bf-blender-cvs] [9bfd4ae2229] master: LibOverride: tweak resync detection code at apply phase.

Bastien Montagne noreply at git.blender.org
Wed Aug 18 16:53:58 CEST 2021


Commit: 9bfd4ae22293caedfb8e150512cc911bfc95d35f
Author: Bastien Montagne
Date:   Wed Aug 18 12:53:15 2021 +0200
Branches: master
https://developer.blender.org/rB9bfd4ae22293caedfb8e150512cc911bfc95d35f

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.

===================================================================

M	source/blender/makesrna/intern/rna_access_compare_override.c

===================================================================

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);
   }



More information about the Bf-blender-cvs mailing list