Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <bastien@blender.org>2021-09-23 14:46:55 +0300
committerBastien Montagne <bastien@blender.org>2021-09-23 14:48:41 +0300
commit4d2ca33a8a7d08897a273031099da9b7bcaa11ff (patch)
tree65ee3094fb3c1c7ecee28f39f501e10a651a8cc9
parentaadb7ef0718af9c54fa97d0ce10e3967a80cea2e (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.
-rw-r--r--source/blender/editors/screen/workspace_edit.c9
-rw-r--r--source/blender/windowmanager/WM_api.h6
-rw-r--r--source/blender/windowmanager/intern/wm_dragdrop.c7
-rw-r--r--source/blender/windowmanager/intern/wm_files_link.c18
4 files changed, 28 insertions, 12 deletions
diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c
index b99cb831bee..4b81e713080 100644
--- a/source/blender/editors/screen/workspace_edit.c
+++ b/source/blender/editors/screen/workspace_edit.c
@@ -310,7 +310,14 @@ static int workspace_append_activate_exec(bContext *C, wmOperator *op)
RNA_string_get(op->ptr, "filepath", filepath);
WorkSpace *appended_workspace = (WorkSpace *)WM_file_append_datablock(
- bmain, CTX_data_scene(C), CTX_data_view_layer(C), CTX_wm_view3d(C), filepath, ID_WS, idname);
+ bmain,
+ CTX_data_scene(C),
+ CTX_data_view_layer(C),
+ CTX_wm_view3d(C),
+ filepath,
+ ID_WS,
+ idname,
+ BLO_LIBLINK_APPEND_RECURSIVE);
if (appended_workspace) {
/* Set defaults. */
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;
}