From c7e989bd32c9f0029f5ff0bc110136a6a1496c52 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 19 Sep 2024 16:25:06 +0200 Subject: [PATCH] Fix #126205: Do not rebuild collection caches on any ID deletion. Deleting ID would systematically call `BKE_main_collection_sync_remap`, which would invalidate all collection caches. This should only be needed when deleting a Scene, Collection or Object ID. Pull Request: https://projects.blender.org/blender/blender/pulls/127866 --- source/blender/blenkernel/intern/lib_id_delete.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/lib_id_delete.cc b/source/blender/blenkernel/intern/lib_id_delete.cc index af524e88847..9020f1aa637 100644 --- a/source/blender/blenkernel/intern/lib_id_delete.cc +++ b/source/blender/blenkernel/intern/lib_id_delete.cc @@ -181,6 +181,8 @@ void BKE_id_free_ex(Main *bmain, void *idv, const int flag_orig, const bool use_ BKE_layer_collection_resync_forbid(); } + const ID_Type id_type = GS(static_cast(idv)->name); + int flag_final = id_free(bmain, idv, flag_orig, use_flag_from_idtag); if (bmain) { @@ -189,7 +191,9 @@ void BKE_id_free_ex(Main *bmain, void *idv, const int flag_orig, const bool use_ } if ((flag_final & LIB_ID_FREE_NO_MAIN) == 0) { - BKE_main_collection_sync_remap(bmain); + if (ELEM(id_type, ID_SCE, ID_GR, ID_OB)) { + BKE_main_collection_sync_remap(bmain); + } } } }