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-07-27 13:09:32 +0300
committerBastien Montagne <bastien@blender.org>2022-07-27 16:33:29 +0300
commit58dcd2099876d679f7bc51901c82b2f04e9ce659 (patch)
treee8d501ed12d55787762dc89751a048a25d75bb85 /source/blender/blenkernel/intern/lib_id.c
parent4843b161d6cc14045f05d8df76f39795d5fcc6b3 (diff)
ID namemap: Fix more issues when changing libs.
Fix tests, and some issue when making an ID local. There are probably a few more issues still though.
Diffstat (limited to 'source/blender/blenkernel/intern/lib_id.c')
-rw-r--r--source/blender/blenkernel/intern/lib_id.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c
index affa1e72ad0..3778e308db6 100644
--- a/source/blender/blenkernel/intern/lib_id.c
+++ b/source/blender/blenkernel/intern/lib_id.c
@@ -179,6 +179,10 @@ void BKE_lib_id_clear_library_data(Main *bmain, ID *id, const int flags)
const bool id_in_mainlist = (id->tag & LIB_TAG_NO_MAIN) == 0 &&
(id->flag & LIB_EMBEDDED_DATA) == 0;
+ if (id_in_mainlist) {
+ BKE_main_namemap_remove_name(bmain, id, id->name + 2);
+ }
+
lib_id_library_local_paths(bmain, id->lib, id);
id_fake_user_clear(id);
@@ -1080,6 +1084,9 @@ void *BKE_libblock_alloc(Main *bmain, short type, const char *name, const int fl
/* alphabetic insertion: is in new_id */
BKE_main_unlock(bmain);
+ /* This assert avoids having to keep name_map consistency when changing the library of an ID,
+ * if this check is not true anymore it will have to be done here too. */
+ BLI_assert(bmain->curlib == NULL || bmain->curlib->runtime.name_map == NULL);
/* This is important in 'readfile doversion after liblink' context mainly, but is a good
* consistency change in general: ID created for a Main should get that main's current
* library pointer. */