Fix: crash in liboverride hierarchy ensure

Add null checks to logging and fix typo in if-check.

Pull Request: https://projects.blender.org/blender/blender/pulls/111055
This commit is contained in:
RedMser
2023-08-11 21:21:21 +02:00
committed by Gitea
parent c40e3dd142
commit baeeff9a84

View File

@@ -1774,16 +1774,20 @@ void BKE_lib_override_library_main_hierarchy_root_ensure(Main *bmain)
int best_level = 0;
ID *id_root = lib_override_root_find(bmain, id, best_level, &best_level);
if (!ELEM(id_root->override_library->hierarchy_root, id_root, nullptr)) {
if (!ELEM(id->override_library->hierarchy_root, id_root, nullptr)) {
/* FIXME This is probably never actually reached with current code? Check above for non-null
* hierarchy root pointer either skip the rest of the loop, or reset it to nullptr. */
CLOG_WARN(&LOG,
"Potential inconsistency in library override hierarchy of ID '%s' (current root "
"%s), detected as part of the hierarchy of '%s' (current root '%s')",
id->name,
id->override_library->hierarchy_root->name,
id->override_library->hierarchy_root != nullptr ?
id->override_library->hierarchy_root->name :
"<NONE>",
id_root->name,
id_root->override_library->hierarchy_root->name);
id_root->override_library->hierarchy_root != nullptr ?
id_root->override_library->hierarchy_root->name :
"<NONE>");
processed_ids.add(id);
continue;
}