diff options
author | Julian Eisel <julian@blender.org> | 2021-07-30 16:54:54 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2021-07-30 16:54:54 +0300 |
commit | eb2a6f454bd07442d16001e25dcf407d4e8f7533 (patch) | |
tree | 9ad9b0edcd4e6f0522dd0fb2a847108a169d8322 /source/blender/windowmanager/intern | |
parent | 4647ffd918225452f25bd865a386e292ba7ebac8 (diff) |
Fix T90318: Dragging asset while Asset Browser is still loading crashes
This partially reverts cb0b017d8f51: We can't store the asset handle in
the drag data, because the file pointer it wraps may be freed as the
Asset Browser generates its file list.
Diffstat (limited to 'source/blender/windowmanager/intern')
-rw-r--r-- | source/blender/windowmanager/intern/wm_dragdrop.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c index 319e83f667f..db72dd2a819 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.c +++ b/source/blender/windowmanager/intern/wm_dragdrop.c @@ -42,8 +42,6 @@ #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" @@ -198,7 +196,6 @@ 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); @@ -376,14 +373,13 @@ wmDragAsset *WM_drag_get_asset_data(const wmDrag *drag, int idcode) } wmDragAsset *asset_drag = drag->poin; - ID_Type idtype = ED_asset_handle_get_id_type(asset_drag->asset_handle); - return (ELEM(idcode, 0, (int)idtype)) ? asset_drag : NULL; + return (ELEM(idcode, 0, asset_drag->id_type)) ? 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); + const char *name = asset_drag->name; + ID_Type idtype = asset_drag->id_type; switch ((eFileAssetImportType)asset_drag->import_type) { case FILE_ASSET_IMPORT_LINK: @@ -449,8 +445,7 @@ void WM_drag_free_imported_drag_ID(struct Main *bmain, wmDrag *drag, wmDropBox * return; } - ID_Type idtype = ED_asset_handle_get_id_type(asset_drag->asset_handle); - ID *id = BKE_libblock_find_name(bmain, idtype, name); + ID *id = BKE_libblock_find_name(bmain, asset_drag->id_type, name); if (id) { BKE_id_delete(bmain, id); } @@ -484,7 +479,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 ED_asset_handle_get_name(asset_drag->asset_handle); + return asset_drag->name; } case WM_DRAG_PATH: case WM_DRAG_NAME: |