From: ewt Date: Wed, 12 Jan 2000 14:57:28 +0000 (+0000) Subject: fixed: X-Git-Tag: r0-50-2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dc59858610278ce8222b1cf033b62b4b671660a7;p=thirdparty%2Fnewt.git fixed: 1. if an empty listbox has the focus and the user presses a key which isn't defined as a hotkey by its form, the program crashes. 2. if the program uses newtListboxSetCurrent() to select an item which is not displayed because it is beyond the bottom of the widget, the refresh code doesn't make it visible. --- diff --git a/listbox.c b/listbox.c index dc96665..ef276ae 100644 --- a/listbox.c +++ b/listbox.c @@ -174,10 +174,10 @@ void newtListboxSetCurrent(newtComponent co, int num) if (li->currItem < li->startShowItem) li->startShowItem = li->currItem; - else if (li->currItem - li->startShowItem > co->height - 1) - li->startShowItem = li->currItem - co->height + 1; - if (li->startShowItem + co->height > li->numItems) - li->startShowItem = li->numItems - co->height; + else if (li->currItem - li->startShowItem > li->curHeight - 1) + li->startShowItem = li->currItem - li->curHeight + 1; + if (li->startShowItem + li->curHeight > li->numItems) + li->startShowItem = li->numItems - li->curHeight; if(li->startShowItem < 0) li->startShowItem = 0; @@ -629,6 +629,7 @@ static struct eventResult listboxEvent(newtComponent co, struct event ev) { er.result = ER_SWALLOWED; break; default: + if (li->numItems <= 0) break; if (ev.u.key < NEWT_KEY_EXTRA_BASE && isalpha(ev.u.key)) { for(i = 0, item = li->boxItems; item != NULL && i < li->currItem; i++, item = item->next);