diff options
author | Bastien Montagne <bastien@blender.org> | 2021-09-09 11:48:26 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2021-09-09 11:51:10 +0300 |
commit | 0c0e5a84204bda817c1e77a82cc7099aca4cf5be (patch) | |
tree | d5873fe1a5327104260bf15231b5f375dd48a4cf /source/blender/blenkernel/intern/object.c | |
parent | f8ead736a017a013777bd9e20a76b461bd990dad (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/object.c')
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index aea8d84047d..b4343578eab 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -331,8 +331,8 @@ static void object_make_local(Main *bmain, ID *id, const int flags) Object *ob = (Object *)id; const bool lib_local = (flags & LIB_ID_MAKELOCAL_FULL_LIBRARY) != 0; const bool clear_proxy = (flags & LIB_ID_MAKELOCAL_OBJECT_NO_PROXY_CLEARING) == 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; @@ -346,32 +346,38 @@ static void object_make_local(Main *bmain, ID *id, const int flags) if (!force_local && !force_copy) { BKE_library_ID_test_usages(bmain, ob, &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, &ob->id); - BKE_lib_id_expand_local(bmain, &ob->id); - if (clear_proxy) { - if (ob->proxy_from != NULL) { - ob->proxy_from->proxy = NULL; - ob->proxy_from->proxy_group = NULL; - } - ob->proxy = ob->proxy_from = ob->proxy_group = NULL; + if (force_local) { + BKE_lib_id_clear_library_data(bmain, &ob->id); + BKE_lib_id_expand_local(bmain, &ob->id); + if (clear_proxy) { + if (ob->proxy_from != NULL) { + ob->proxy_from->proxy = NULL; + ob->proxy_from->proxy_group = NULL; } + ob->proxy = ob->proxy_from = ob->proxy_group = NULL; } - else { - Object *ob_new = (Object *)BKE_id_copy(bmain, &ob->id); - id_us_min(&ob_new->id); + } + else if (force_copy) { + Object *ob_new = (Object *)BKE_id_copy(bmain, &ob->id); + id_us_min(&ob_new->id); - ob_new->proxy = ob_new->proxy_from = ob_new->proxy_group = NULL; + ob_new->proxy = ob_new->proxy_from = ob_new->proxy_group = NULL; - /* setting newid is mandatory for complex make_lib_local logic... */ - ID_NEW_SET(ob, ob_new); + /* setting newid is mandatory for complex make_lib_local logic... */ + ID_NEW_SET(ob, ob_new); - if (!lib_local) { - BKE_libblock_remap(bmain, ob, ob_new, ID_REMAP_SKIP_INDIRECT_USAGE); - } + if (!lib_local) { + BKE_libblock_remap(bmain, ob, ob_new, ID_REMAP_SKIP_INDIRECT_USAGE); } } } |