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>2022-10-19 17:47:57 +0300
committerBastien Montagne <bastien@blender.org>2022-10-19 17:52:48 +0300
commitceb0e7fceae52d317833ed05e6ee0b2852ad170d (patch)
tree0f14cef1067ca5a13d318c31fc40ab79f55cf266 /source/blender
parentd763e294fc68226af320b9fe17ad50e2b21287ce (diff)
Fix (devs-reported) mistake in batch delete code in recent change.
Mistake in own rB358155a8da60, change ended up discarding the case where we need to also delete IDs using a tagged-to-be-deleted ID in a 'never NULL' way. Typical example: Whene deleting a Mesh ID, one also needs to delete all the Objects using that mesh, since obdata pointer is of type 'never NULL'. Note that luckily, this fix does not affect the performance improvements from rB358155a8da60. Noted by Brecht and Clement because of failing unittests, shame on me.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/intern/lib_id_delete.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/source/blender/blenkernel/intern/lib_id_delete.c b/source/blender/blenkernel/intern/lib_id_delete.c
index ae5dc75c36a..1a80376f482 100644
--- a/source/blender/blenkernel/intern/lib_id_delete.c
+++ b/source/blender/blenkernel/intern/lib_id_delete.c
@@ -218,6 +218,7 @@ static size_t id_delete(Main *bmain, const bool do_tagged_deletion)
BKE_main_lock(bmain);
if (do_tagged_deletion) {
struct IDRemapper *id_remapper = BKE_id_remapper_create();
+ BKE_layer_collection_resync_forbid();
/* Main idea of batch deletion is to remove all IDs to be deleted from Main database.
* This means that we won't have to loop over all deleted IDs to remove usages
@@ -253,22 +254,20 @@ static size_t id_delete(Main *bmain, const bool do_tagged_deletion)
}
}
}
- }
-
- BKE_layer_collection_resync_forbid();
- /* Will tag 'never NULL' users of this ID too.
- *
- * NOTE: #BKE_libblock_unlink() cannot be used here, since it would ignore indirect
- * links, this can lead to nasty crashing here in second, actual deleting loop.
- * Also, this will also flag users of deleted data that cannot be unlinked
- * (object using deleted obdata, etc.), so that they also get deleted. */
- BKE_libblock_remap_multiple_locked(bmain,
- id_remapper,
- ID_REMAP_FLAG_NEVER_NULL_USAGE |
- ID_REMAP_FORCE_NEVER_NULL_USAGE |
- ID_REMAP_FORCE_INTERNAL_RUNTIME_POINTERS);
- BKE_id_remapper_clear(id_remapper);
+ /* Will tag 'never NULL' users of this ID too.
+ *
+ * NOTE: #BKE_libblock_unlink() cannot be used here, since it would ignore indirect
+ * links, this can lead to nasty crashing here in second, actual deleting loop.
+ * Also, this will also flag users of deleted data that cannot be unlinked
+ * (object using deleted obdata, etc.), so that they also get deleted. */
+ BKE_libblock_remap_multiple_locked(bmain,
+ id_remapper,
+ ID_REMAP_FLAG_NEVER_NULL_USAGE |
+ ID_REMAP_FORCE_NEVER_NULL_USAGE |
+ ID_REMAP_FORCE_INTERNAL_RUNTIME_POINTERS);
+ BKE_id_remapper_clear(id_remapper);
+ }
/* Since we removed IDs from Main, their own other IDs usages need to be removed 'manually'. */
LinkNode *cleanup_ids = NULL;