Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <bastien@blender.org>2021-02-25 17:48:28 +0300
committerBastien Montagne <bastien@blender.org>2021-02-25 19:48:54 +0300
commit1df6cd67a15235baececea0d75739c68747a725c (patch)
tree629a06d40a6ad5a0b1dd04765e7eb0e5ef194cfc
parentb958a59c791f3f3ecd9039886b85920f0b12548c (diff)
Fix (unreported) bad usercount handling in batch ID deletion.
This was rather obscure and non-critical issue, but in some cases ID usercount of some deleted IDs from batch-deletion code would not be properly nullified, which would then assert later in actual deletion code.
-rw-r--r--source/blender/blenkernel/intern/lib_id_delete.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/source/blender/blenkernel/intern/lib_id_delete.c b/source/blender/blenkernel/intern/lib_id_delete.c
index 8075660dcd1..7c5032c97f4 100644
--- a/source/blender/blenkernel/intern/lib_id_delete.c
+++ b/source/blender/blenkernel/intern/lib_id_delete.c
@@ -305,13 +305,16 @@ static size_t id_delete(Main *bmain, const bool do_tagged_deletion)
/* Since we removed ID from Main,
* we also need to unlink its own other IDs usages ourself. */
BKE_libblock_relink_ex(bmain, id, NULL, NULL, 0);
- /* Now we can safely mark that ID as not being in Main database anymore. */
- id->tag |= LIB_TAG_NO_MAIN;
- /* This is needed because we may not have remapped usages
- * of that ID by other deleted ones. */
- // id->us = 0; /* Is it actually? */
}
}
+
+ /* Now we can safely mark that ID as not being in Main database anymore. */
+ /* NOTE: This needs to be done in a separate loop than above, otherwise some usercounts of
+ * deleted IDs may not be properly decreased by the remappings (since `NO_MAIN` ID usercounts
+ * is never affected). */
+ for (ID *id = tagged_deleted_ids.first; id; id = id->next) {
+ id->tag |= LIB_TAG_NO_MAIN;
+ }
}
else {
/* First tag all datablocks directly from target lib.