diff --git a/source/blender/blenkernel/intern/context.cc b/source/blender/blenkernel/intern/context.cc index 3e62607c023..5b1d875fe73 100644 --- a/source/blender/blenkernel/intern/context.cc +++ b/source/blender/blenkernel/intern/context.cc @@ -1529,20 +1529,6 @@ const AssetLibraryReference *CTX_wm_asset_library_ref(const bContext *C) return static_cast(ctx_data_pointer_get(C, "asset_library_reference")); } -static AssetHandle ctx_wm_asset_handle(const bContext *C, bool *r_is_valid) -{ - /* TODO remove and use #AssetRepresentation instead. */ - FileDirEntry *file = - (FileDirEntry *)CTX_data_pointer_get_type(C, "active_file", &RNA_FileSelectEntry).data; - if (file && file->asset) { - *r_is_valid = true; - return AssetHandle{file}; - } - - *r_is_valid = false; - return AssetHandle{nullptr}; -} - blender::asset_system::AssetRepresentation *CTX_wm_asset(const bContext *C) { if (auto *asset = static_cast( @@ -1550,14 +1536,6 @@ blender::asset_system::AssetRepresentation *CTX_wm_asset(const bContext *C) { return asset; } - - /* Expose the asset representation from the asset-handle. - * TODO(Julian): #AssetHandle should be properly replaced by #AssetRepresentation. */ - bool is_valid; - if (AssetHandle handle = ctx_wm_asset_handle(C, &is_valid); is_valid) { - return handle.file_data->asset; - } - return nullptr; } diff --git a/source/blender/editors/space_file/file_context.cc b/source/blender/editors/space_file/file_context.cc index 1c79f81caae..51ea4143b25 100644 --- a/source/blender/editors/space_file/file_context.cc +++ b/source/blender/editors/space_file/file_context.cc @@ -20,6 +20,7 @@ const char *file_context_dir[] = { "active_file", "selected_files", "asset_library_reference", + "asset", "selected_assets", "id", "selected_ids", @@ -79,6 +80,16 @@ int /*eContextResult*/ file_context(const bContext *C, result, &screen->id, &RNA_AssetLibraryReference, &asset_params->asset_library_ref); return CTX_RESULT_OK; } + + if (CTX_data_equals(member, "asset")) { + FileDirEntry *file = filelist_file(sfile->files, params->active_file); + if (file == nullptr) { + return CTX_RESULT_NO_DATA; + } + + CTX_data_pointer_set(result, &screen->id, &RNA_AssetRepresentation, file->asset); + return CTX_RESULT_OK; + } if (CTX_data_equals(member, "selected_assets")) { const int num_files_filtered = filelist_files_ensure(sfile->files);