diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2016-07-20 20:49:45 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2016-07-21 17:54:36 +0300 |
commit | d8d4bef6ccc3556a5691e5b633ebad895a795872 (patch) | |
tree | 2faf0473d311809060e6d2e7cfa9c813d1880100 /source/blender/blenkernel/intern/image.c | |
parent | 2977dcf2f7471e00079100803fd4203fcf97f20a (diff) |
Refactor/deduplicate even more make_local code (and fix part of T48907).
Turns out most BKE_foo_make_local datablock-specific functions are actually doing
exactly the same thing, only two currently need special additional operations
(object and brush ones). So added a BKE_id_make_local_generic instead
of copying same code over and over.
Also, changed a bit how make_local works in case we are localizing a whole library.
We need to do the 'remap' step (from old linked ID to new local one) in the second loop,
otherwise we miss some dependencies. This fixes main part of T48907.
Diffstat (limited to 'source/blender/blenkernel/intern/image.c')
-rw-r--r-- | source/blender/blenkernel/intern/image.c | 29 |
1 files changed, 2 insertions, 27 deletions
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 0032eb35d3a..44bea5c8138 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -469,34 +469,9 @@ Image *BKE_image_copy(Main *bmain, Image *ima) return nima; } -void BKE_image_make_local(Main *bmain, Image *ima, const bool force_local) +void BKE_image_make_local(Main *bmain, Image *ima, const bool lib_local) { - bool is_local = false, is_lib = false; - - /* - only lib users: do nothing (unless force_local is set) - * - only local users: set flag - * - mixed: make copy - */ - - if (!ID_IS_LINKED_DATABLOCK(ima)) { - return; - } - - BKE_library_ID_test_usages(bmain, ima, &is_local, &is_lib); - - if (force_local || is_local) { - if (!is_lib) { - id_clear_lib_data(bmain, &ima->id); - BKE_id_expand_local(&ima->id); - } - else { - Image *ima_new = BKE_image_copy(bmain, ima); - - ima_new->id.us = 0; - - BKE_libblock_remap(bmain, ima, ima_new, ID_REMAP_SKIP_INDIRECT_USAGE); - } - } + BKE_id_make_local_generic(bmain, &ima->id, true, lib_local); } void BKE_image_merge(Image *dest, Image *source) |