diff options
author | Jeroen Bakker <jeroen@blender.org> | 2022-01-25 17:31:46 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2022-01-25 17:31:46 +0300 |
commit | 460e0a1347e50d33f5d42235ee2d9cb7208cdc4f (patch) | |
tree | 76f51516a6865d42315f9f6f5b30147d75082dcb /source/blender/blenkernel/intern/lib_remap.c | |
parent | 33ba298b5db24b002d936e135c3c84aa2300e6db (diff) |
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)
Diffstat (limited to 'source/blender/blenkernel/intern/lib_remap.c')
-rw-r--r-- | source/blender/blenkernel/intern/lib_remap.c | 66 |
1 files changed, 10 insertions, 56 deletions
diff --git a/source/blender/blenkernel/intern/lib_remap.c b/source/blender/blenkernel/intern/lib_remap.c index c3ccedb9608..ec97ca83703 100644 --- a/source/blender/blenkernel/intern/lib_remap.c +++ b/source/blender/blenkernel/intern/lib_remap.c @@ -510,18 +510,11 @@ static void libblock_remap_data( #endif } -typedef struct LibblockRemapMultipleUserData { - Main *bmain; - short remap_flags; -} LibBlockRemapMultipleUserData; - -static void libblock_remap_foreach_idpair_cb(ID *old_id, ID *new_id, void *user_data) +void BKE_libblock_remap_locked(Main *bmain, void *old_idv, void *new_idv, const short remap_flags) { - LibBlockRemapMultipleUserData *data = user_data; - Main *bmain = data->bmain; - const short remap_flags = data->remap_flags; - IDRemap id_remap_data; + ID *old_id = old_idv; + ID *new_id = new_idv; int skipped_direct, skipped_refcounted; BLI_assert(old_id != NULL); @@ -534,6 +527,13 @@ static void libblock_remap_foreach_idpair_cb(ID *old_id, ID *new_id, void *user_ free_notifier_reference_cb(old_id); } + /* We assume editors do not hold references to their IDs... This is false in some cases + * (Image is especially tricky here), + * editors' code is to handle refcount (id->us) itself then. */ + if (remap_editor_id_reference_cb) { + remap_editor_id_reference_cb(old_id, new_id); + } + skipped_direct = id_remap_data.skipped_direct; skipped_refcounted = id_remap_data.skipped_refcounted; @@ -606,41 +606,6 @@ static void libblock_remap_foreach_idpair_cb(ID *old_id, ID *new_id, void *user_ DEG_relations_tag_update(bmain); } -void BKE_libblock_remap_multiple_locked(Main *bmain, - const struct IDRemapper *mappings, - const short remap_flags) -{ - if (BKE_id_remapper_is_empty(mappings)) { - /* Early exit nothing to do. */ - return; - } - - LibBlockRemapMultipleUserData user_data; - user_data.bmain = bmain; - user_data.remap_flags = remap_flags; - BKE_id_remapper_iter(mappings, libblock_remap_foreach_idpair_cb, &user_data); - - /* We assume editors do not hold references to their IDs... This is false in some cases - * (Image is especially tricky here), - * editors' code is to handle refcount (id->us) itself then. */ - if (remap_editor_id_reference_cb) { - remap_editor_id_reference_cb(mappings); - } - - /* Full rebuild of DEG! */ - DEG_relations_tag_update(bmain); -} - -void BKE_libblock_remap_locked(Main *bmain, void *old_idv, void *new_idv, const short remap_flags) -{ - struct IDRemapper *remapper = BKE_id_remapper_create(); - ID *old_id = old_idv; - ID *new_id = new_idv; - BKE_id_remapper_add(remapper, old_id, new_id); - BKE_libblock_remap_multiple_locked(bmain, remapper, remap_flags); - BKE_id_remapper_free(remapper); -} - void BKE_libblock_remap(Main *bmain, void *old_idv, void *new_idv, const short remap_flags) { BKE_main_lock(bmain); @@ -650,17 +615,6 @@ void BKE_libblock_remap(Main *bmain, void *old_idv, void *new_idv, const short r BKE_main_unlock(bmain); } -void BKE_libblock_remap_multiple(Main *bmain, - const struct IDRemapper *mappings, - const short remap_flags) -{ - BKE_main_lock(bmain); - - BKE_libblock_remap_multiple_locked(bmain, mappings, remap_flags); - - BKE_main_unlock(bmain); -} - void BKE_libblock_unlink(Main *bmain, void *idv, const bool do_flag_never_null, |