diff options
Diffstat (limited to 'source/blender/windowmanager/intern')
-rw-r--r-- | source/blender/windowmanager/intern/wm_dragdrop.c | 25 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 2 |
2 files changed, 25 insertions, 2 deletions
diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c index bad58c32cdb..f78bd528c5e 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.c +++ b/source/blender/windowmanager/intern/wm_dragdrop.c @@ -40,6 +40,7 @@ #include "BKE_context.h" #include "BKE_global.h" +#include "BKE_idprop.h" #include "BKE_idtype.h" #include "BKE_lib_id.h" #include "BKE_main.h" @@ -405,11 +406,15 @@ bool WM_drag_is_ID_type(const wmDrag *drag, int idcode) /** * \note: Does not store \a asset in any way, so it's fine to pass a temporary. */ -wmDragAsset *WM_drag_create_asset_data(const AssetHandle *asset, const char *path, int import_type) +wmDragAsset *WM_drag_create_asset_data(const AssetHandle *asset, + AssetMetaData *metadata, + const char *path, + int import_type) { wmDragAsset *asset_drag = MEM_mallocN(sizeof(*asset_drag), "wmDragAsset"); BLI_strncpy(asset_drag->name, ED_asset_handle_get_name(asset), sizeof(asset_drag->name)); + asset_drag->metadata = metadata; asset_drag->path = path; asset_drag->id_type = ED_asset_handle_get_id_type(asset); asset_drag->import_type = import_type; @@ -433,6 +438,21 @@ wmDragAsset *WM_drag_get_asset_data(const wmDrag *drag, int idcode) return (ELEM(idcode, 0, asset_drag->id_type)) ? asset_drag : NULL; } +struct AssetMetaData *WM_drag_get_asset_meta_data(const wmDrag *drag, int idcode) +{ + wmDragAsset *drag_asset = WM_drag_get_asset_data(drag, idcode); + if (drag_asset) { + return drag_asset->metadata; + } + + ID *local_id = WM_drag_get_local_ID(drag, idcode); + if (local_id) { + return local_id->asset_data; + } + + return NULL; +} + static ID *wm_drag_asset_id_import(wmDragAsset *asset_drag) { const char *name = asset_drag->name; @@ -566,11 +586,12 @@ void WM_drag_add_asset_list_item( drag_asset->asset_data.local_id = local_id; } else { + AssetMetaData *metadata = ED_asset_handle_get_metadata(asset); char asset_blend_path[FILE_MAX_LIBEXTRA]; ED_asset_handle_get_full_library_path(C, asset_library_ref, asset, asset_blend_path); drag_asset->is_external = true; drag_asset->asset_data.external_info = WM_drag_create_asset_data( - asset, BLI_strdup(asset_blend_path), FILE_ASSET_IMPORT_APPEND); + asset, metadata, BLI_strdup(asset_blend_path), FILE_ASSET_IMPORT_APPEND); } BLI_addtail(&drag->asset_items, drag_asset); } diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 2525c627785..8fcc30dfed7 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -1788,6 +1788,7 @@ static bool wm_file_write(bContext *C, /* Call pre-save callbacks before writing preview, * that way you can generate custom file thumbnail. */ BKE_callback_exec_null(bmain, BKE_CB_EVT_SAVE_PRE); + ED_assets_pre_save(bmain); /* Enforce full override check/generation on file save. */ BKE_lib_override_library_main_operations_create(bmain, true); @@ -2105,6 +2106,7 @@ static int wm_homefile_write_exec(bContext *C, wmOperator *op) } BKE_callback_exec_null(bmain, BKE_CB_EVT_SAVE_PRE); + ED_assets_pre_save(bmain); /* check current window and close it if temp */ if (win && WM_window_is_temp_screen(win)) { |