Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2018-10-30 12:54:02 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-10-30 13:00:25 +0300
commit4669c3692cc4f69660c673ceccce2245d5b9fed8 (patch)
treea0d23c2993066a063e8e5425ccfdcb11d3909215 /source/blender/editors/interface/interface_utils.c
parent76a047893cecdc987965011b1f63373b14922969 (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/interface/interface_utils.c')
-rw-r--r--source/blender/editors/interface/interface_utils.c13
1 files changed, 10 insertions, 3 deletions
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++;