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-30 16:54:54 +0300
committerJulian Eisel <julian@blender.org>2021-07-30 16:54:54 +0300
commiteb2a6f454bd07442d16001e25dcf407d4e8f7533 (patch)
tree9ad9b0edcd4e6f0522dd0fb2a847108a169d8322 /source/blender/windowmanager
parent4647ffd918225452f25bd865a386e292ba7ebac8 (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')
-rw-r--r--source/blender/windowmanager/WM_types.h7
-rw-r--r--source/blender/windowmanager/intern/wm_dragdrop.c15
2 files changed, 10 insertions, 12 deletions
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index cc8fb307c92..4ead0b2699c 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -924,10 +924,13 @@ typedef struct wmDragID {
} wmDragID;
typedef struct wmDragAsset {
- /* Owning pointer. Contains the file with all the asset data (name, local ID, etc.) */
- struct AssetHandle *asset_handle;
+ /* Note: Can't store the AssetHandle here, since the FileDirEntry it wraps may be freed while
+ * dragging. So store necessary data here directly. */
+
+ char name[64]; /* MAX_NAME */
/* 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 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: