diff options
author | Ton Roosendaal <ton@blender.org> | 2010-12-28 14:56:18 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2010-12-28 14:56:18 +0300 |
commit | 875a7288ca0ecd141fbe943fa67feb45cdd70f55 (patch) | |
tree | b5f54e071a347b129e3e0704780a183fc5bf5c7a | |
parent | 46891eec31e4525311d6c2a3627aec64ef3b313e (diff) |
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.
-rw-r--r-- | source/blender/editors/interface/interface_regions.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index d22106fc6a1..1da50e0a9bb 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -1082,28 +1082,35 @@ void ui_searchbox_free(bContext *C, ARegion *ar) } /* 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); } |