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 10:18:47 +0300
committerPhilipp Oeser <info@graphics-engineer.com>2022-10-26 12:54:20 +0300
commit514f4e8b47bf4c3d57cf74780cb3b8178e8f1a19 (patch)
treee47144520ded5de440546fda44aa89d602397496
parent94ec66c2f2859c717789a41cd5b8f0af0d7ec379 (diff)
Fix T101903: Crash when deleting library in some cases.
Remapping in batch deletion could end up calling viewlayer resync code on partially invalid BMain (some IDs still in Main using IDs removed from Main). Think this code can actually be further optimized, but this fix should be safe enough for 3.3 (and potentially 2.93). Thanks to Jeroen (@jbakker) for the initial investigation.
-rw-r--r--source/blender/blenkernel/intern/lib_id_delete.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/lib_id_delete.c b/source/blender/blenkernel/intern/lib_id_delete.c
index 8d5699d7d49..78e800e1fdb 100644
--- a/source/blender/blenkernel/intern/lib_id_delete.c
+++ b/source/blender/blenkernel/intern/lib_id_delete.c
@@ -23,6 +23,7 @@
#include "BKE_idprop.h"
#include "BKE_idtype.h"
#include "BKE_key.h"
+#include "BKE_layer.h"
#include "BKE_lib_id.h"
#include "BKE_lib_override.h"
#include "BKE_lib_remap.h"
@@ -217,6 +218,7 @@ static size_t id_delete(Main *bmain, const bool do_tagged_deletion)
BKE_main_lock(bmain);
if (do_tagged_deletion) {
+ 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
* of other deleted IDs.
@@ -279,6 +281,9 @@ static size_t id_delete(Main *bmain, const bool do_tagged_deletion)
}
}
+ BKE_layer_collection_resync_allow();
+ BKE_main_collection_sync_remap(bmain);
+
/* 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