diff options
Diffstat (limited to 'source/blender/blenkernel/intern/library.c')
-rw-r--r-- | source/blender/blenkernel/intern/library.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 3dc7997ca79..fc584e172a1 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -251,6 +251,33 @@ void id_fake_user_clear(ID *id) } } +static int id_expand_local_callback(void *user_data, struct ID *UNUSED(id_self), struct ID **id_pointer, int cd_flag) +{ + const bool do_user_count = (user_data != NULL); + + /* We tag all ID usages as extern, and increase usercount in case it was requested. */ + if (*id_pointer) { + if (do_user_count && (cd_flag & IDWALK_USER)) { + id_us_plus(*id_pointer); + } + else { + id_lib_extern(*id_pointer); + } + } + + return IDWALK_RET_NOP; +} + +/** + * Expand ID usages of given id as 'extern' (and no more indirect) linked data. Used by ID copy/make_local functions. + * + * \param do_user_count If true, increase usercount of refcounted datablocks used by given id (use it with copied id). + */ +void BKE_id_expand_local(struct ID *id, const bool do_user_count) +{ + BKE_library_foreach_ID_link(id, id_expand_local_callback, SET_INT_IN_POINTER((int)do_user_count), 0); +} + /* calls the appropriate make_local method for the block, unless test. Returns true * if the block can be made local. */ bool id_make_local(Main *bmain, ID *id, bool test) |