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:
authorJulian Eisel <julian@blender.org>2021-07-20 22:26:55 +0300
committerJulian Eisel <julian@blender.org>2021-07-20 22:30:04 +0300
commitcb0b017d8f5178b58a59c66e9588199f2864608b (patch)
tree964a1532fc149534b3a4b6d34323f70bb51cc60e /source/blender/windowmanager
parent0af08cea40964b69a48a2be773aeb22304d2b46f (diff)
Cleanup: Store asset-handle in drag data
Would previously pass a few properties that are available via the asset-handle now. This asset-handle is also required for some of the asset API, e.g. the temporary ID loading. This will probably be needed before too long.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r--source/blender/windowmanager/WM_types.h4
-rw-r--r--source/blender/windowmanager/intern/wm_dragdrop.c20
2 files changed, 15 insertions, 9 deletions
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index 2b48a5f6648..cc8fb307c92 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -924,10 +924,10 @@ typedef struct wmDragID {
} wmDragID;
typedef struct wmDragAsset {
- char name[64]; /* MAX_NAME */
+ /* Owning pointer. Contains the file with all the asset data (name, local ID, etc.) */
+ struct AssetHandle *asset_handle;
/* Always freed. */
const char *path;
- int id_type;
int import_type; /* eFileAssetImportType */
} wmDragAsset;
diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c
index da40040ce56..319e83f667f 100644
--- a/source/blender/windowmanager/intern/wm_dragdrop.c
+++ b/source/blender/windowmanager/intern/wm_dragdrop.c
@@ -42,6 +42,8 @@
#include "BKE_idtype.h"
#include "BKE_lib_id.h"
+#include "ED_asset.h"
+
#include "GPU_shader.h"
#include "GPU_state.h"
#include "GPU_viewport.h"
@@ -196,6 +198,7 @@ void WM_drag_data_free(int dragtype, void *poin)
/* Not too nice, could become a callback. */
if (dragtype == WM_DRAG_ASSET) {
wmDragAsset *asset_drag = poin;
+ MEM_SAFE_FREE(asset_drag->asset_handle);
MEM_freeN((void *)asset_drag->path);
}
MEM_freeN(poin);
@@ -373,18 +376,20 @@ wmDragAsset *WM_drag_get_asset_data(const wmDrag *drag, int idcode)
}
wmDragAsset *asset_drag = drag->poin;
- return (ELEM(idcode, 0, asset_drag->id_type)) ? asset_drag : NULL;
+ ID_Type idtype = ED_asset_handle_get_id_type(asset_drag->asset_handle);
+ return (ELEM(idcode, 0, (int)idtype)) ? asset_drag : NULL;
}
static ID *wm_drag_asset_id_import(wmDragAsset *asset_drag)
{
+ const char *name = ED_asset_handle_get_name(asset_drag->asset_handle);
+ ID_Type idtype = ED_asset_handle_get_id_type(asset_drag->asset_handle);
+
switch ((eFileAssetImportType)asset_drag->import_type) {
case FILE_ASSET_IMPORT_LINK:
- return WM_file_link_datablock(
- G_MAIN, NULL, NULL, NULL, asset_drag->path, asset_drag->id_type, asset_drag->name);
+ return WM_file_link_datablock(G_MAIN, NULL, NULL, NULL, asset_drag->path, idtype, name);
case FILE_ASSET_IMPORT_APPEND:
- return WM_file_append_datablock(
- G_MAIN, NULL, NULL, NULL, asset_drag->path, asset_drag->id_type, asset_drag->name);
+ return WM_file_append_datablock(G_MAIN, NULL, NULL, NULL, asset_drag->path, idtype, name);
}
BLI_assert_unreachable();
@@ -444,7 +449,8 @@ void WM_drag_free_imported_drag_ID(struct Main *bmain, wmDrag *drag, wmDropBox *
return;
}
- ID *id = BKE_libblock_find_name(bmain, asset_drag->id_type, name);
+ ID_Type idtype = ED_asset_handle_get_id_type(asset_drag->asset_handle);
+ ID *id = BKE_libblock_find_name(bmain, idtype, name);
if (id) {
BKE_id_delete(bmain, id);
}
@@ -478,7 +484,7 @@ static const char *wm_drag_name(wmDrag *drag)
}
case WM_DRAG_ASSET: {
const wmDragAsset *asset_drag = WM_drag_get_asset_data(drag, 0);
- return asset_drag->name;
+ return ED_asset_handle_get_name(asset_drag->asset_handle);
}
case WM_DRAG_PATH:
case WM_DRAG_NAME: