[Bf-blender-cvs] [6c679aca177] blender-v3.2-release: LibOverride: Make process checking validity of hierarchy roots more robust.

Bastien Montagne noreply at git.blender.org
Tue May 10 17:43:35 CEST 2022


Commit: 6c679aca1770c37a32c089512d47d98ae795284b
Author: Bastien Montagne
Date:   Tue May 10 17:32:31 2022 +0200
Branches: blender-v3.2-release
https://developer.blender.org/rB6c679aca1770c37a32c089512d47d98ae795284b

LibOverride: Make process checking validity of hierarchy roots more robust.

Code was not really designed to hanlde corrupted (e.g. local ID) root
hierarchies, now it should handle better those invalid cases and restore
proper sane situation as best as possible.

Fixes crashes with some corrupted files from Blender studio.

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

M	source/blender/blenkernel/intern/lib_override.c

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

diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c
index a2338eb9b39..3c115ba3a74 100644
--- a/source/blender/blenkernel/intern/lib_override.c
+++ b/source/blender/blenkernel/intern/lib_override.c
@@ -1384,7 +1384,21 @@ void BKE_lib_override_library_main_hierarchy_root_ensure(Main *bmain)
       continue;
     }
     if (id->override_library->hierarchy_root != NULL) {
-      continue;
+      if (!ID_IS_OVERRIDE_LIBRARY_REAL(id->override_library->hierarchy_root) ||
+          id->override_library->hierarchy_root->lib != id->lib) {
+        CLOG_ERROR(
+            &LOG,
+            "Existing override hierarchy root ('%s') for ID '%s' is invalid, will try to find a "
+            "new valid one",
+            id->override_library->hierarchy_root != NULL ?
+                id->override_library->hierarchy_root->name :
+                "<NONE>",
+            id->name);
+        id->override_library->hierarchy_root = NULL;
+      }
+      else {
+        continue;
+      }
     }
 
     BKE_main_relations_tag_set(bmain, MAINIDRELATIONS_ENTRY_TAGS_PROCESSED, false);
@@ -2058,6 +2072,10 @@ static bool lib_override_resync_tagging_finalize_recurse(
 
     CLOG_INFO(&LOG, 4, "Found root ID '%s' for resync root ID '%s'", id_root->name, id->name);
 
+    if (id_root->override_library == NULL) {
+      BLI_assert(0);
+    }
+
     LinkNodePair **id_resync_roots_p;
     if (!BLI_ghash_ensure_p(id_roots, id_root, (void ***)&id_resync_roots_p)) {
       *id_resync_roots_p = MEM_callocN(sizeof(**id_resync_roots_p), __func__);



More information about the Bf-blender-cvs mailing list