diff options
author | Bastien Montagne <bastien@blender.org> | 2021-09-23 14:46:55 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2021-09-23 14:48:41 +0300 |
commit | 4d2ca33a8a7d08897a273031099da9b7bcaa11ff (patch) | |
tree | 65ee3094fb3c1c7ecee28f39f501e10a651a8cc9 /source/blender/windowmanager | |
parent | aadb7ef0718af9c54fa97d0ce10e3967a80cea2e (diff) |
LibLink: Modify WM API to link/append one ID to take flag parameter.
There is no reason to lock behavior into a specific configuration in
those calls, make them properly configurable like the rest of the
link/append code.
This also enable users of those functions to activate 'ID reuse'
behavior.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 6 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_dragdrop.c | 7 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files_link.c | 18 |
3 files changed, 20 insertions, 11 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 6794b1f4091..c5482a729c3 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -212,14 +212,16 @@ struct ID *WM_file_link_datablock(struct Main *bmain, struct View3D *v3d, const char *filepath, const short id_code, - const char *id_name); + const char *id_name, + int flag); struct ID *WM_file_append_datablock(struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer, struct View3D *v3d, const char *filepath, const short id_code, - const char *id_name); + const char *id_name, + int flag); void WM_lib_reload(struct Library *lib, struct bContext *C, struct ReportList *reports); /* mouse cursors */ diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c index 6585349c83c..f3a57b72095 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.c +++ b/source/blender/windowmanager/intern/wm_dragdrop.c @@ -43,6 +43,8 @@ #include "BKE_idtype.h" #include "BKE_lib_id.h" +#include "BLO_readfile.h" + #include "GPU_shader.h" #include "GPU_state.h" #include "GPU_viewport.h" @@ -392,9 +394,10 @@ static ID *wm_drag_asset_id_import(wmDragAsset *asset_drag) switch ((eFileAssetImportType)asset_drag->import_type) { case FILE_ASSET_IMPORT_LINK: - return WM_file_link_datablock(G_MAIN, NULL, NULL, NULL, asset_drag->path, idtype, name); + return WM_file_link_datablock(G_MAIN, NULL, NULL, NULL, asset_drag->path, idtype, name, 0); case FILE_ASSET_IMPORT_APPEND: - return WM_file_append_datablock(G_MAIN, NULL, NULL, NULL, asset_drag->path, idtype, name); + return WM_file_append_datablock( + G_MAIN, NULL, NULL, NULL, asset_drag->path, idtype, name, BLO_LIBLINK_APPEND_RECURSIVE); } BLI_assert_unreachable(); diff --git a/source/blender/windowmanager/intern/wm_files_link.c b/source/blender/windowmanager/intern/wm_files_link.c index 2f34ee3db3c..92335f28d94 100644 --- a/source/blender/windowmanager/intern/wm_files_link.c +++ b/source/blender/windowmanager/intern/wm_files_link.c @@ -1331,14 +1331,14 @@ static ID *wm_file_link_append_datablock_ex(Main *bmain, const char *filepath, const short id_code, const char *id_name, - const bool do_append) + const int flag) { + const bool do_append = (flag & FILE_LINK) == 0; /* Tag everything so we can make local only the new datablock. */ BKE_main_id_tag_all(bmain, LIB_TAG_PRE_EXISTING, true); /* Define working data, with just the one item we want to link. */ - WMLinkAppendData *lapp_data = wm_link_append_data_new(do_append ? BLO_LIBLINK_APPEND_RECURSIVE : - 0); + WMLinkAppendData *lapp_data = wm_link_append_data_new(flag); wm_link_append_data_library_add(lapp_data, filepath); WMLinkAppendDataItem *item = wm_link_append_data_item_add(lapp_data, id_name, id_code, NULL); @@ -1371,10 +1371,12 @@ ID *WM_file_link_datablock(Main *bmain, View3D *v3d, const char *filepath, const short id_code, - const char *id_name) + const char *id_name, + int flag) { + flag |= FILE_LINK; return wm_file_link_append_datablock_ex( - bmain, scene, view_layer, v3d, filepath, id_code, id_name, false); + bmain, scene, view_layer, v3d, filepath, id_code, id_name, flag); } /* @@ -1387,10 +1389,12 @@ ID *WM_file_append_datablock(Main *bmain, View3D *v3d, const char *filepath, const short id_code, - const char *id_name) + const char *id_name, + int flag) { + BLI_assert((flag & FILE_LINK) == 0); ID *id = wm_file_link_append_datablock_ex( - bmain, scene, view_layer, v3d, filepath, id_code, id_name, true); + bmain, scene, view_layer, v3d, filepath, id_code, id_name, flag); return id; } |