[Bf-blender-cvs] [a229a9dd648] master: Fix T91461: Pose Library name filter not working
Philipp Oeser
noreply at git.blender.org
Sat Sep 18 08:25:28 CEST 2021
Commit: a229a9dd64821575b27e6e6e317a1ce97e23f6d7
Author: Philipp Oeser
Date: Fri Sep 17 11:30:05 2021 +0200
Branches: master
https://developer.blender.org/rBa229a9dd64821575b27e6e6e317a1ce97e23f6d7
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
===================================================================
M source/blender/editors/interface/interface_template_list.cc
===================================================================
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]) {
More information about the Bf-blender-cvs
mailing list