From 460e0a1347e50d33f5d42235ee2d9cb7208cdc4f Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Tue, 25 Jan 2022 15:31:46 +0100 Subject: Revert "Performance: Remap multiple items in UI" This reverts commit 948211679f2a0681421160be0d3b90f507bc0be7. This commit introduced some regressions in the test suite. As this change is a core part of blender Bastien and I decided to revert it as the solution isn't clear and needs more investigation. The following tests FAILED: 62 - blendfile_liblink (SEGFAULT) 63 - blendfile_library_overrides (SEGFAULT) It fails in (id_us_ensure_real) --- source/blender/blenkernel/intern/lib_id_delete.c | 39 +++++++++--------------- 1 file changed, 14 insertions(+), 25 deletions(-) (limited to 'source/blender/blenkernel/intern/lib_id_delete.c') diff --git a/source/blender/blenkernel/intern/lib_id_delete.c b/source/blender/blenkernel/intern/lib_id_delete.c index f4dd67cac28..6d2e89187f7 100644 --- a/source/blender/blenkernel/intern/lib_id_delete.c +++ b/source/blender/blenkernel/intern/lib_id_delete.c @@ -154,10 +154,7 @@ void BKE_id_free_ex(Main *bmain, void *idv, int flag, const bool use_flag_from_i } if (remap_editor_id_reference_cb) { - struct IDRemapper *remapper = BKE_id_remapper_create(); - BKE_id_remapper_add(remapper, id, NULL); - remap_editor_id_reference_cb(remapper); - BKE_id_remapper_free(remapper); + remap_editor_id_reference_cb(id, NULL); } } @@ -295,40 +292,32 @@ static size_t id_delete(Main *bmain, const bool do_tagged_deletion) * Note that we go forward here, since we want to check dependencies before users * (e.g. meshes before objects). * Avoids to have to loop twice. */ - struct IDRemapper *remapper = BKE_id_remapper_create(); for (i = 0; i < base_count; i++) { ListBase *lb = lbarray[i]; ID *id, *id_next; - BKE_id_remapper_clear(remapper); for (id = lb->first; id; id = id_next) { id_next = id->next; /* NOTE: in case we delete a library, we also delete all its datablocks! */ if ((id->tag & tag) || (id->lib != NULL && (id->lib->id.tag & tag))) { id->tag |= tag; - BKE_id_remapper_add(remapper, id, NULL); - } - } - if (BKE_id_remapper_is_empty(remapper)) { - continue; + /* Will tag 'never NULL' users of this ID too. + * Note that we cannot use BKE_libblock_unlink() here, since it would ignore indirect + * (and proxy!) 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_locked(bmain, + id, + NULL, + (ID_REMAP_FLAG_NEVER_NULL_USAGE | + ID_REMAP_FORCE_NEVER_NULL_USAGE | + ID_REMAP_FORCE_INTERNAL_RUNTIME_POINTERS)); + } } - - /* Will tag 'never NULL' users of this ID too. - * Note that we cannot use BKE_libblock_unlink() here, since it would ignore indirect - * (and proxy!) 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, - remapper, - (ID_REMAP_FLAG_NEVER_NULL_USAGE | - ID_REMAP_FORCE_NEVER_NULL_USAGE | - ID_REMAP_FORCE_INTERNAL_RUNTIME_POINTERS)); } - BKE_id_remapper_free(remapper); } - BKE_main_unlock(bmain); /* In usual reversed order, such that all usage of a given ID, even 'never NULL' ones, -- cgit v1.2.3