[Bf-blender-cvs] [5625a21fc7c] blender-v3.2-release: Fix fuzzy ID deletion user count check.

Bastien Montagne noreply at git.blender.org
Fri May 27 10:50:04 CEST 2022


Commit: 5625a21fc7cf3738278f02038cb6d8a3c2344584
Author: Bastien Montagne
Date:   Fri May 27 10:45:31 2022 +0200
Branches: blender-v3.2-release
https://developer.blender.org/rB5625a21fc7cf3738278f02038cb6d8a3c2344584

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.

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

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

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

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;



More information about the Bf-blender-cvs mailing list