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
This commit is contained in:
Bastien Montagne
2024-09-19 16:25:06 +02:00
parent adf990f5e1
commit c7e989bd32
@@ -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<ID *>(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);
}
}
}
}