[Bf-blender-cvs] [77a90f7666b] blender2.8: Fix crash when using template_search with non-ID data

Julian Eisel noreply at git.blender.org
Sat May 13 19:48:47 CEST 2017


Commit: 77a90f7666bf6eb78b8f22ab4abae300aae10ef9
Author: Julian Eisel
Date:   Sat May 13 19:48:04 2017 +0200
Branches: blender2.8
https://developer.blender.org/rB77a90f7666bf6eb78b8f22ab4abae300aae10ef9

Fix crash when using template_search with non-ID data

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

M	source/blender/editors/interface/interface_utils.c

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

diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c
index f2e79ec0c7f..f383719a747 100644
--- a/source/blender/editors/interface/interface_utils.c
+++ b/source/blender/editors/interface/interface_utils.c
@@ -214,11 +214,12 @@ int uiDefAutoButsRNA(
 
 	return tot;
 }
+
 /* *** RNA collection search menu *** */
 
 typedef struct CollItemSearch {
 	struct CollItemSearch *next, *prev;
-	ID *id;
+	void *data;
 	char *name;
 	int index;
 	int iconid;
@@ -247,7 +248,6 @@ void ui_rna_collection_search_cb(const struct bContext *C, void *arg, const char
 	/* build a temporary list of relevant items first */
 	RNA_PROP_BEGIN (&data->search_ptr, itemptr, data->search_prop)
 	{
-		ID *id = NULL;
 
 		if (flag & PROP_ID_SELF_CHECK)
 			if (itemptr.data == data->target_ptr.id.data)
@@ -262,14 +262,13 @@ void ui_rna_collection_search_cb(const struct bContext *C, void *arg, const char
 		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)) {
-			id = itemptr.data;
-			iconid = ui_id_icon_get(C, id, false);
+			iconid = ui_id_icon_get(C, itemptr.data, false);
 		}
 
 		if (name) {
 			if (skip_filter || BLI_strcasestr(name, str)) {
 				cis = MEM_callocN(sizeof(CollItemSearch), "CollectionItemSearch");
-				cis->id = id;
+				cis->data = itemptr.data;
 				cis->name = MEM_dupallocN(name);
 				cis->index = i;
 				cis->iconid = iconid;
@@ -286,8 +285,7 @@ void ui_rna_collection_search_cb(const struct bContext *C, void *arg, const char
 
 	/* add search items from temporary list */
 	for (cis = items_list->first; cis; cis = cis->next) {
-		void *poin = cis->id ? cis->id : SET_INT_IN_POINTER(cis->index);
-		if (UI_search_item_add(items, cis->name, poin, cis->iconid) == false) {
+		if (UI_search_item_add(items, cis->name, cis->data, cis->iconid) == false) {
 			break;
 		}
 	}




More information about the Bf-blender-cvs mailing list