[Bf-blender-cvs] [a0a0edc3994] asset-browser-poselib: Fix File Browser double-click not working while in pose mode

Julian Eisel noreply at git.blender.org
Tue Mar 30 18:46:23 CEST 2021


Commit: a0a0edc399424f40a9a570008452884a432319c4
Author: Julian Eisel
Date:   Tue Mar 30 18:42:39 2021 +0200
Branches: asset-browser-poselib
https://developer.blender.org/rBa0a0edc399424f40a9a570008452884a432319c4

Fix File Browser double-click not working while in pose mode

The pose apply operator would be invoked when double-clicking a
directory in the File Browser, while in pose mode.
The operator's poll would succeed because since 29887bbb329d, the
File/Asset Browser would just create a `AssetHandle` from the active
file received from context, without ensuring that the file actually
represents an asset.

===================================================================

M	source/blender/blenkernel/intern/context.c
M	source/blender/editors/asset/asset_edit.cc
M	source/blender/editors/space_file/space_file.c

===================================================================

diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index f287a46a5cb..b55b8ee8d32 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -1421,7 +1421,7 @@ AssetHandle CTX_wm_asset_handle(const bContext *C, bool *r_is_valid)
    * require returning a non-owning pointer, which we don't have in the Asset Browser (yet). */
   FileDirEntry *file =
       (FileDirEntry *)CTX_data_pointer_get_type(C, "active_file", &RNA_FileSelectEntry).data;
-  if (file) {
+  if (file && file->asset_data) {
     *r_is_valid = true;
     return (AssetHandle){.file_data = file};
   }
diff --git a/source/blender/editors/asset/asset_edit.cc b/source/blender/editors/asset/asset_edit.cc
index e4c6f94ed24..48bd1188471 100644
--- a/source/blender/editors/asset/asset_edit.cc
+++ b/source/blender/editors/asset/asset_edit.cc
@@ -195,6 +195,7 @@ AssetTempIDConsumer *ED_asset_temp_id_consumer_create(const AssetHandle *handle)
   if (!handle) {
     return nullptr;
   }
+  BLI_assert(handle->file_data->asset_data != nullptr);
   return reinterpret_cast<AssetTempIDConsumer *>(
       OBJECT_GUARDED_NEW(AssetTemporaryIDConsumer, *handle));
 }
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index 6cf75a67432..210f78033ca 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -886,6 +886,9 @@ static int /*eContextResult*/ file_context(const bContext *C,
   }
   if (CTX_data_equals(member, "asset_library")) {
     FileAssetSelectParams *asset_params = ED_fileselect_get_asset_params(sfile);
+    if (!asset_params) {
+      return CTX_RESULT_NO_DATA;
+    }
 
     BLI_STATIC_ASSERT(offsetof(FileSelectAssetLibraryUID, type) ==
                           offsetof(AssetLibraryReference, type),



More information about the Bf-blender-cvs mailing list