[Bf-blender-cvs] [97dd1070709] master: Fix T98029: Support isolated islands of IDs when purging unused ones.
Bastien Montagne
noreply at git.blender.org
Thu Jul 7 13:01:07 CEST 2022
Commit: 97dd10707097536df24dd7ca7d2a45b9a6408711
Author: Bastien Montagne
Date: Thu Jul 7 12:33:45 2022 +0200
Branches: master
https://developer.blender.org/rB97dd10707097536df24dd7ca7d2a45b9a6408711
Fix T98029: Support isolated islands of IDs when purging unused ones.
Cases were e.g. an object would use a material, and this material would
use this object (e.g. through a driver), even if both those data-blocks
are technically unused, they would remain forever since they were not
detected as such.
Now this is properly detected and purged as part of the 'recursive
purge' operation.
===================================================================
M source/blender/blenkernel/intern/lib_query.c
===================================================================
diff --git a/source/blender/blenkernel/intern/lib_query.c b/source/blender/blenkernel/intern/lib_query.c
index 5de8704e13b..38252a46b93 100644
--- a/source/blender/blenkernel/intern/lib_query.c
+++ b/source/blender/blenkernel/intern/lib_query.c
@@ -693,6 +693,13 @@ static void lib_query_unused_ids_tag_recurse(Main *bmain,
* First recursively check all its valid users, if all of them can be tagged as
* unused, then we can tag this ID as such too. */
bool has_valid_from_users = false;
+ /* Preemptively consider this ID as unused. That way if there is a loop of dependency leading
+ * back to it, it won't create a fake 'valid user' detection.
+ * NOTE: This can only only be done for a subset of IDs, some types are never 'indirectly
+ * unused', same for IDs with a fake user. */
+ if ((id->flag & LIB_FAKEUSER) == 0 && !ELEM(GS(id->name), ID_SCE, ID_WM, ID_SCR, ID_WS, ID_LI)) {
+ id->tag |= tag;
+ }
for (MainIDRelationsEntryItem *id_from_item = id_relations->from_ids; id_from_item != NULL;
id_from_item = id_from_item->next) {
if ((id_from_item->usage_flag & ignored_usages) != 0 ||
@@ -715,7 +722,11 @@ static void lib_query_unused_ids_tag_recurse(Main *bmain,
break;
}
}
- if (!has_valid_from_users) {
+ if (has_valid_from_users) {
+ /* This ID has 'valid' users, clear the 'tag as unused' preemptively set above. */
+ id->tag &= ~tag;
+ }
+ else {
/* This ID has no 'valid' users, tag it as unused. */
id->tag |= tag;
if (r_num_tagged != NULL) {
More information about the Bf-blender-cvs
mailing list