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>2021-09-09 11:48:26 +0300
committerBastien Montagne <bastien@blender.org>2021-09-09 11:51:10 +0300
commit0c0e5a84204bda817c1e77a82cc7099aca4cf5be (patch)
treed5873fe1a5327104260bf15231b5f375dd48a4cf /source/blender/blenkernel/intern/lib_id.c
parentf8ead736a017a013777bd9e20a76b461bd990dad (diff)
IDmanagement: makelocal: Fix mistake in recent commit.
rB8cc3d2d6f51f introduced option to force make_local code to either copy or actually make a linked ID local, but logic of boolean options handling was broken. This commit simplifies logic here and fixes the issue. NOTE: Since those new options were not used yet this was a harmless bug.
Diffstat (limited to 'source/blender/blenkernel/intern/lib_id.c')
-rw-r--r--source/blender/blenkernel/intern/lib_id.c74
1 files changed, 40 insertions, 34 deletions
diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c
index cd0c3635dac..66b83272769 100644
--- a/source/blender/blenkernel/intern/lib_id.c
+++ b/source/blender/blenkernel/intern/lib_id.c
@@ -411,8 +411,8 @@ void BKE_lib_id_make_local_generic(Main *bmain, ID *id, const int flags)
}
const bool lib_local = (flags & LIB_ID_MAKELOCAL_FULL_LIBRARY) != 0;
- const bool force_local = (flags & LIB_ID_MAKELOCAL_FORCE_LOCAL) != 0;
- const bool force_copy = (flags & LIB_ID_MAKELOCAL_FORCE_COPY) != 0;
+ bool force_local = (flags & LIB_ID_MAKELOCAL_FORCE_LOCAL) != 0;
+ bool force_copy = (flags & LIB_ID_MAKELOCAL_FORCE_COPY) != 0;
BLI_assert(force_copy == false || force_copy != force_local);
bool is_local = false, is_lib = false;
@@ -426,43 +426,49 @@ void BKE_lib_id_make_local_generic(Main *bmain, ID *id, const int flags)
if (!force_copy && !force_local) {
BKE_library_ID_test_usages(bmain, id, &is_local, &is_lib);
+ if (lib_local || is_local) {
+ if (!is_lib) {
+ force_local = true;
+ }
+ else {
+ force_copy = true;
+ }
+ }
}
- if (lib_local || is_local || force_copy || force_local) {
- if (!is_lib || force_local) {
- BKE_lib_id_clear_library_data(bmain, id);
- BKE_lib_id_expand_local(bmain, id);
- }
- else {
- ID *id_new = BKE_id_copy(bmain, id);
-
- /* Should not fail in expected use cases,
- * but a few ID types cannot be copied (LIB, WM, SCR...). */
- if (id_new != NULL) {
- id_new->us = 0;
-
- /* setting newid is mandatory for complex make_lib_local logic... */
- ID_NEW_SET(id, id_new);
- Key *key = BKE_key_from_id(id), *key_new = BKE_key_from_id(id);
- if (key && key_new) {
- ID_NEW_SET(key, key_new);
- }
- bNodeTree *ntree = ntreeFromID(id), *ntree_new = ntreeFromID(id_new);
- if (ntree && ntree_new) {
- ID_NEW_SET(ntree, ntree_new);
- }
- if (GS(id->name) == ID_SCE) {
- Collection *master_collection = ((Scene *)id)->master_collection,
- *master_collection_new = ((Scene *)id_new)->master_collection;
- if (master_collection && master_collection_new) {
- ID_NEW_SET(master_collection, master_collection_new);
- }
- }
+ if (force_local) {
+ BKE_lib_id_clear_library_data(bmain, id);
+ BKE_lib_id_expand_local(bmain, id);
+ }
+ else if (force_copy) {
+ ID *id_new = BKE_id_copy(bmain, id);
+
+ /* Should not fail in expected use cases,
+ * but a few ID types cannot be copied (LIB, WM, SCR...). */
+ if (id_new != NULL) {
+ id_new->us = 0;
- if (!lib_local) {
- BKE_libblock_remap(bmain, id, id_new, ID_REMAP_SKIP_INDIRECT_USAGE);
+ /* setting newid is mandatory for complex make_lib_local logic... */
+ ID_NEW_SET(id, id_new);
+ Key *key = BKE_key_from_id(id), *key_new = BKE_key_from_id(id);
+ if (key && key_new) {
+ ID_NEW_SET(key, key_new);
+ }
+ bNodeTree *ntree = ntreeFromID(id), *ntree_new = ntreeFromID(id_new);
+ if (ntree && ntree_new) {
+ ID_NEW_SET(ntree, ntree_new);
+ }
+ if (GS(id->name) == ID_SCE) {
+ Collection *master_collection = ((Scene *)id)->master_collection,
+ *master_collection_new = ((Scene *)id_new)->master_collection;
+ if (master_collection && master_collection_new) {
+ ID_NEW_SET(master_collection, master_collection_new);
}
}
+
+ if (!lib_local) {
+ BKE_libblock_remap(bmain, id, id_new, ID_REMAP_SKIP_INDIRECT_USAGE);
+ }
}
}
}