diff options
author | Bastien Montagne <bastien@blender.org> | 2022-05-27 11:45:31 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2022-05-27 11:49:53 +0300 |
commit | 5625a21fc7cf3738278f02038cb6d8a3c2344584 (patch) | |
tree | ee8adc53702eb2898c7e5b7599fe1cb6dd81d790 /source/blender/blenkernel | |
parent | bf53956914732bfd3e25806867ebe63081f7486d (diff) |
Fix fuzzy ID deletion user count check.
`BKE_id_delete` should only check for consistency of user count with
regards to the tags and flags of the ID, not 'protect' nor even warn in
case a 'fake user' ID is deleted (such higher-level checks are to be
handled by higher-level code).
Also replace the assert + debug print by a CLOG error, this avoids
'assert crash' while still failing tests, and always producing a useful
message.
Fixes T98374 and T98260.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/lib_id_delete.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/lib_id_delete.c b/source/blender/blenkernel/intern/lib_id_delete.c index 904039d56c8..f14c11a949e 100644 --- a/source/blender/blenkernel/intern/lib_id_delete.c +++ b/source/blender/blenkernel/intern/lib_id_delete.c @@ -6,6 +6,8 @@ * Contains management of ID's for freeing & deletion. */ +#include "CLG_log.h" + #include "MEM_guardedalloc.h" /* all types are needed here, in order to do memory operations */ @@ -35,8 +37,7 @@ # include "BPY_extern.h" #endif -/* Not used currently. */ -// static CLG_LogRef LOG = {.identifier = "bke.lib_id_delete"}; +static CLG_LogRef LOG = {.identifier = "bke.lib_id_delete"}; void BKE_libblock_free_data(ID *id, const bool do_id_user) { @@ -334,11 +335,13 @@ static size_t id_delete(Main *bmain, const bool do_tagged_deletion) for (id = do_tagged_deletion ? tagged_deleted_ids.first : lb->first; id; id = id_next) { id_next = id->next; if (id->tag & tag) { - if (id->us != 0) { -#ifdef DEBUG_PRINT - printf("%s: deleting %s (%d)\n", __func__, id->name, id->us); -#endif - BLI_assert(id->us == 0); + if (((id->tag & LIB_TAG_EXTRAUSER_SET) == 0 && ID_REAL_USERS(id) != 0) || + ((id->tag & LIB_TAG_EXTRAUSER_SET) != 0 && ID_REAL_USERS(id) != 1)) { + CLOG_ERROR(&LOG, + "Deleting %s which still has %d users (including %d 'extra' shallow users)\n", + id->name, + ID_REAL_USERS(id), + (id->tag & LIB_TAG_EXTRAUSER_SET) != 0 ? 1 : 0); } BKE_id_free_ex(bmain, id, free_flag, !do_tagged_deletion); ++num_datablocks_deleted; |