[Bf-blender-cvs] [c67873e49b7] master: LibOverride: Silence some more asserts.

Bastien Montagne noreply at git.blender.org
Fri Sep 25 11:09:56 CEST 2020


Commit: c67873e49b784e799360d07a2a0b78e03eac00b3
Author: Bastien Montagne
Date:   Fri Sep 25 11:07:04 2020 +0200
Branches: master
https://developer.blender.org/rBc67873e49b784e799360d07a2a0b78e03eac00b3

LibOverride: Silence some more asserts.

Print out messages into console instead when se cannot find expected
data (this is actually normal when source library gets edited).

Note that there seems to be some issue with the 'auto-cleanup' mechanism
removing no more valid override rules on file save, will check on that
next.

Related to T81059, found while investigating it.

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

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

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

diff --git a/source/blender/makesrna/intern/rna_access_compare_override.c b/source/blender/makesrna/intern/rna_access_compare_override.c
index c97f5c4c52e..40b04399ac9 100644
--- a/source/blender/makesrna/intern/rna_access_compare_override.c
+++ b/source/blender/makesrna/intern/rna_access_compare_override.c
@@ -908,9 +908,18 @@ static void rna_property_override_apply_ex(Main *bmain,
       if (opop->subitem_local_name != NULL) {
         RNA_property_collection_lookup_string(
             ptr_src, prop_src, opop->subitem_local_name, &private_ptr_item_src);
-        if (opop->subitem_reference_name != NULL) {
-          RNA_property_collection_lookup_string(
-              ptr_dst, prop_dst, opop->subitem_reference_name, &private_ptr_item_dst);
+        if (opop->subitem_reference_name != NULL &&
+            RNA_property_collection_lookup_string(
+                ptr_dst, prop_dst, opop->subitem_reference_name, &private_ptr_item_dst)) {
+          /* This is rather fragile, but the fact that local override IDs may have a different name
+           * than their linked reference makes it necessary.
+           * Basically, here we are considering that if we cannot find the original linked ID in
+           * the local override we are (re-)applying the operations, then it may be because soe of
+           * those operations have already been applied, and we may already have the local ID
+           * pointer we want to set.
+           * This happens e.g. during resync of an override, since we have already remapped all ID
+           * pointers to their expected values.
+           * In that case we simply try to get the property from the local expected name. */
         }
         else {
           RNA_property_collection_lookup_string(
@@ -962,6 +971,17 @@ static void rna_property_override_apply_ex(Main *bmain,
       ptr_item_dst = &private_ptr_item_dst;
       ptr_item_src = &private_ptr_item_src;
       ptr_item_storage = &private_ptr_item_storage;
+
+      if (ptr_item_dst->type == NULL) {
+        printf("Failed to find destination sub-item '%s' in new override data '%s'\n",
+               opop->subitem_reference_name,
+               ptr_dst->owner_id->name);
+      }
+      if (ptr_item_src->type == NULL) {
+        printf("Failed to find source sub-item '%s' in old override data '%s'\n",
+               opop->subitem_local_name,
+               ptr_src->owner_id->name);
+      }
     }
 
     if (!rna_property_override_operation_apply(bmain,
diff --git a/source/blender/makesrna/intern/rna_collection.c b/source/blender/makesrna/intern/rna_collection.c
index b0250897d6d..69f8bd85975 100644
--- a/source/blender/makesrna/intern/rna_collection.c
+++ b/source/blender/makesrna/intern/rna_collection.c
@@ -167,13 +167,17 @@ static bool rna_Collection_objects_override_apply(Main *bmain,
   Collection *coll_dst = (Collection *)ptr_dst->owner_id;
 
   if (ptr_item_dst->type == NULL || ptr_item_src->type == NULL) {
-    BLI_assert(0 && "invalid source or destination object.");
+    //    BLI_assert(0 && "invalid source or destination object.");
     return false;
   }
 
   Object *ob_dst = ptr_item_dst->data;
   Object *ob_src = ptr_item_src->data;
 
+  if (ob_src == ob_dst) {
+    return true;
+  }
+
   CollectionObject *cob_dst = BLI_findptr(
       &coll_dst->gobject, ob_dst, offsetof(CollectionObject, ob));



More information about the Bf-blender-cvs mailing list