From 641a5be50e03f4a7152dd37e97680bee26dc3e6f Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 21 Oct 2021 12:55:15 +0200 Subject: IDManagement: Add option to clear asset data when making ID local. When appending an asset from the asset browser, its asset data needs to be cleared. However, linking an asset (or regular append from the file browser) should not clear such data. In linking case, it would be there again after a blend file reload anyway. So this commit introduces a new `BLO_LIBLINK_APPEND_ASSET_DATA_CLEAR` option. NOTE: in case the appended ID needs to be copied from its linked data (instead of making the later directly local), asset data is lost anyway since it is never copied with the ID currently. Ref. {T91749} and D11768. --- source/blender/windowmanager/intern/wm_files_link.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'source/blender/windowmanager/intern/wm_files_link.c') diff --git a/source/blender/windowmanager/intern/wm_files_link.c b/source/blender/windowmanager/intern/wm_files_link.c index d193c5663f0..c88e577df6a 100644 --- a/source/blender/windowmanager/intern/wm_files_link.c +++ b/source/blender/windowmanager/intern/wm_files_link.c @@ -630,6 +630,12 @@ static void wm_append_do(WMLinkAppendData *lapp_data, const bool set_fakeuser = (lapp_data->flag & BLO_LIBLINK_APPEND_SET_FAKEUSER) != 0; const bool do_reuse_local_id = (lapp_data->flag & BLO_LIBLINK_APPEND_LOCAL_ID_REUSE) != 0; + const int make_local_common_flags = LIB_ID_MAKELOCAL_FULL_LIBRARY | + ((lapp_data->flag & BLO_LIBLINK_APPEND_ASSET_DATA_CLEAR) != + 0 ? + LIB_ID_MAKELOCAL_ASSET_DATA_CLEAR : + 0); + LinkNode *itemlink; /* Generate a mapping between newly linked IDs and their items, and tag linked IDs used as @@ -731,16 +737,14 @@ static void wm_append_do(WMLinkAppendData *lapp_data, BLI_strncpy(lib_id_name, id->name, sizeof(lib_id_name)); switch (item->append_action) { - case WM_APPEND_ACT_COPY_LOCAL: { - BKE_lib_id_make_local( - bmain, id, LIB_ID_MAKELOCAL_FULL_LIBRARY | LIB_ID_MAKELOCAL_FORCE_COPY); + case WM_APPEND_ACT_COPY_LOCAL: + BKE_lib_id_make_local(bmain, id, make_local_common_flags | LIB_ID_MAKELOCAL_FORCE_COPY); local_appended_new_id = id->newid; break; - } case WM_APPEND_ACT_MAKE_LOCAL: BKE_lib_id_make_local(bmain, id, - LIB_ID_MAKELOCAL_FULL_LIBRARY | LIB_ID_MAKELOCAL_FORCE_LOCAL | + make_local_common_flags | LIB_ID_MAKELOCAL_FORCE_LOCAL | LIB_ID_MAKELOCAL_OBJECT_NO_PROXY_CLEARING); BLI_assert(id->newid == NULL); local_appended_new_id = id; -- cgit v1.2.3