diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2016-12-12 16:58:10 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2016-12-12 16:58:10 +0300 |
commit | b708dce34f8caa52efba7ddf7ed00582a36e38f9 (patch) | |
tree | d1ad9398b143a8e01e5748d07480634facbf8c31 /source/blender/blenkernel/intern | |
parent | efadc8051eaca1202d5f7074b8a644b26eb54e75 (diff) |
Cleanup: Rename BKE_libblock_relink, and move it to BKE_library_remap.h
Was a waaaaayyyyy to much generic name for such a specific func, renamed
to much more descriptive BKE_libblock_relink_to_newid().
In near future (few weeks, to limit as much as possible silent mismatch
in branches), will rename BKE_libblock_relink_ex to BKE_libblock_relink,
this is the real generic data-block relinking func!
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/library.c | 25 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/library_remap.c | 29 |
2 files changed, 29 insertions, 25 deletions
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 31c10c843da..65f37d0a5b1 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1173,31 +1173,6 @@ void *BKE_libblock_copy_nolib(ID *id, const bool do_action) return idn; } -static int id_relink_looper(void *UNUSED(user_data), ID *UNUSED(self_id), ID **id_pointer, const int cd_flag) -{ - ID *id = *id_pointer; - if (id) { - /* See: NEW_ID macro */ - if (id->newid) { - BKE_library_update_ID_link_user(id->newid, id, cd_flag); - *id_pointer = id->newid; - } - else if (id->tag & LIB_TAG_NEW) { - id->tag &= ~LIB_TAG_NEW; - BKE_libblock_relink(id); - } - } - return IDWALK_RET_NOP; -} - -void BKE_libblock_relink(ID *id) -{ - if (ID_IS_LINKED_DATABLOCK(id)) - return; - - BKE_library_foreach_ID_link(id, id_relink_looper, NULL, 0); -} - void BKE_library_free(Library *lib) { if (lib->packedfile) diff --git a/source/blender/blenkernel/intern/library_remap.c b/source/blender/blenkernel/intern/library_remap.c index 62f59832481..4f1f6d963ed 100644 --- a/source/blender/blenkernel/intern/library_remap.c +++ b/source/blender/blenkernel/intern/library_remap.c @@ -680,6 +680,35 @@ void BKE_libblock_relink_ex( } } +static int id_relink_to_newid_looper(void *UNUSED(user_data), ID *UNUSED(self_id), ID **id_pointer, const int cd_flag) +{ + ID *id = *id_pointer; + if (id) { + /* See: NEW_ID macro */ + if (id->newid) { + BKE_library_update_ID_link_user(id->newid, id, cd_flag); + *id_pointer = id->newid; + } + else if (id->tag & LIB_TAG_NEW) { + id->tag &= ~LIB_TAG_NEW; + BKE_libblock_relink_to_newid(id); + } + } + return IDWALK_RET_NOP; +} + +/** Similar to libblock_relink_ex, but is remapping IDs to their newid value if non-NULL, in given \a id. + * + * Very specific usage, not sure we'll keep it on the long run, currently only used in Object duplication code... + */ +void BKE_libblock_relink_to_newid(ID *id) +{ + if (ID_IS_LINKED_DATABLOCK(id)) + return; + + BKE_library_foreach_ID_link(id, id_relink_to_newid_looper, NULL, 0); +} + void BKE_libblock_free_data(Main *UNUSED(bmain), ID *id) { if (id->properties) { |