diff options
author | Philipp Oeser <info@graphics-engineer.com> | 2021-09-17 12:30:05 +0300 |
---|---|---|
committer | Philipp Oeser <info@graphics-engineer.com> | 2021-09-18 09:13:24 +0300 |
commit | a229a9dd64821575b27e6e6e317a1ce97e23f6d7 (patch) | |
tree | 10c50df53c39f53d201a0ed3e88eb56678b0b0a4 /source/blender/editors/interface/interface_template_list.cc | |
parent | 6cf734a2e5d2496d1b2d33bc7613b56a9f9fc2ec (diff) |
Fix T91461: Pose Library name filter not working
since `AssetHandle` does not have a `name_property`
(`RNA_def_struct_name_property`), and the UIList is just using the
default `uilist_filter_items_default` it simply cannot filter on names
(`RNA_struct_name_get_alloc` wont succeed).
Adding a name_property also wont work since `AssetHandle` inherits
`PropertyGroup` (which already sets name_property).
So this adds a (temporary) hack exception for RNA_AssetHandle in
uilist_filter_items_default until the design of `AssetHandle` progresses
further.
thx @Severin for additional feedback
Maniphest Tasks: T91461
Differential Revision: https://developer.blender.org/D12541
Diffstat (limited to 'source/blender/editors/interface/interface_template_list.cc')
-rw-r--r-- | source/blender/editors/interface/interface_template_list.cc | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/source/blender/editors/interface/interface_template_list.cc b/source/blender/editors/interface/interface_template_list.cc index 8246759ad36..845a7813da2 100644 --- a/source/blender/editors/interface/interface_template_list.cc +++ b/source/blender/editors/interface/interface_template_list.cc @@ -31,6 +31,7 @@ #include "BLT_translation.h" +#include "ED_asset.h" #include "ED_screen.h" #include "MEM_guardedalloc.h" @@ -216,7 +217,18 @@ static void uilist_filter_items_default(struct uiList *ui_list, RNA_PROP_BEGIN (dataptr, itemptr, prop) { bool do_order = false; - char *namebuf = RNA_struct_name_get_alloc(&itemptr, nullptr, 0, nullptr); + char *namebuf; + if (RNA_struct_is_a(itemptr.type, &RNA_AssetHandle)) { + /* XXX The AssetHandle design is hacky and meant to be temporary. It can't have a proper + * name property, so for now this hardcoded exception is needed. */ + AssetHandle *asset_handle = (AssetHandle *)itemptr.data; + const char *asset_name = ED_asset_handle_get_name(asset_handle); + namebuf = BLI_strdup(asset_name); + } + else { + namebuf = RNA_struct_name_get_alloc(&itemptr, nullptr, 0, nullptr); + } + const char *name = namebuf ? namebuf : ""; if (filter[0]) { |