diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2018-10-30 12:54:02 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2018-10-30 13:00:25 +0300 |
commit | 4669c3692cc4f69660c673ceccce2245d5b9fed8 (patch) | |
tree | a0d23c2993066a063e8e5425ccfdcb11d3909215 /source/blender/editors | |
parent | 76a047893cecdc987965011b1f63373b14922969 (diff) |
Add library-hint to datablock search menus.
We had those for ID templates, but it's also tremendously useful for
regular ID pointers UI, since often you can get local and linked
data-block with same exact name...
Fetaure request from Spring team (and long due TODO...).
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 4 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_utils.c | 13 |
2 files changed, 12 insertions, 5 deletions
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 8a1ebbb205c..32b942283c7 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -297,8 +297,8 @@ static bool id_search_add( } if (*str == '\0' || BLI_strcasestr(id->name + 2, str)) { - /* +1 is needed because BKE_id_ui_prefix used 3 letter prefix - * followed by ID_NAME-2 characters from id->name + /* +1 is needed because BKE_id_ui_prefix uses 3 letter prefix + * followed by ID_NAME-2 characters from id->name. */ char name_ui[MAX_ID_NAME + 1]; BKE_id_ui_prefix(name_ui, id); diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c index 507f89f01cd..4a051b9a4e8 100644 --- a/source/blender/editors/interface/interface_utils.c +++ b/source/blender/editors/interface/interface_utils.c @@ -43,6 +43,7 @@ #include "BLT_translation.h" +#include "BKE_library.h" #include "BKE_report.h" #include "MEM_guardedalloc.h" @@ -270,22 +271,28 @@ void ui_rna_collection_search_cb(const struct bContext *C, void *arg, const char continue; } - name = RNA_struct_name_get_alloc(&itemptr, NULL, 0, NULL); /* could use the string length here */ iconid = 0; if (itemptr.type && RNA_struct_is_ID(itemptr.type)) { + name = MEM_malloc_arrayN(MAX_ID_NAME + 1, sizeof(*name), __func__); + BKE_id_ui_prefix(name, itemptr.data); iconid = ui_id_icon_get(C, itemptr.data, false); } + else { + name = RNA_struct_name_get_alloc(&itemptr, NULL, 0, NULL); /* could use the string length here */ + } if (name) { if (skip_filter || BLI_strcasestr(name, str)) { cis = MEM_callocN(sizeof(CollItemSearch), "CollectionItemSearch"); cis->data = itemptr.data; - cis->name = MEM_dupallocN(name); + cis->name = name; /* Still ownership of that memory. */ cis->index = i; cis->iconid = iconid; BLI_addtail(items_list, cis); } - MEM_freeN(name); + else { + MEM_freeN(name); + } } i++; |