[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [33927] trunk/blender/source/blender/ editors/interface/interface_regions.c: Bugfix, irc report.

Ton Roosendaal ton at blender.org
Tue Dec 28 12:56:19 CET 2010


Revision: 33927
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33927
Author:   ton
Date:     2010-12-28 12:56:18 +0100 (Tue, 28 Dec 2010)

Log Message:
-----------
Bugfix, irc report.

UI name buttons with Search callback show red when item couldn't be
found. The check was too simple though, since the searches also find
partial matches. This caused KeyingSet browse to show red for "RotScale".

Now 10 matches are stored, and each match is being checked. Still a
bit weak for cases with more than 10 matches, but in that case it
won't show red-alert.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/interface/interface_regions.c

Modified: trunk/blender/source/blender/editors/interface/interface_regions.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_regions.c	2010-12-28 11:52:35 UTC (rev 33926)
+++ trunk/blender/source/blender/editors/interface/interface_regions.c	2010-12-28 11:56:18 UTC (rev 33927)
@@ -1082,28 +1082,35 @@
 }
 
 /* sets red alert if button holds a string it can't find */
+/* XXX weak: search_func adds all partial matches... */
 void ui_but_search_test(uiBut *but)
 {
 	uiSearchItems *items= MEM_callocN(sizeof(uiSearchItems), "search items");
-	char *strp[2], str[256];
+	int x1;
 	
-	items->maxitem= 1;
+	/* setup search struct */
+	items->maxitem= 10;
 	items->maxstrlen= 256;
-	strp[0]= str;
-	items->names= strp;
+	items->names= MEM_callocN(items->maxitem*sizeof(void *), "search names");
+	for(x1=0; x1<items->maxitem; x1++)
+		items->names[x1]= MEM_callocN(but->hardmax+1, "search names");
 	
-	/* changed flag makes search only find name */
-	but->changed= TRUE;
 	but->search_func(but->block->evil_C, but->search_arg, but->drawstr, items);
-	but->changed= 0;
 	
+	/* only redalert when we are sure of it, this can miss cases when >10 matches */
 	if(items->totitem==0)
 		uiButSetFlag(but, UI_BUT_REDALERT);
-	else if(items->totitem==1) {
-		if(strcmp(but->drawstr, str)!=0)
+	else if(items->more==0) {
+		for(x1= 0; x1<items->totitem; x1++)
+			if(strcmp(but->drawstr, items->names[x1])==0)
+				break;
+		if(x1==items->totitem)
 			uiButSetFlag(but, UI_BUT_REDALERT);
 	}
-				  
+	
+	for(x1=0; x1<items->maxitem; x1++)
+		MEM_freeN(items->names[x1]);
+	MEM_freeN(items->names);
 	MEM_freeN(items);
 }
 





More information about the Bf-blender-cvs mailing list