Fix panel inconsistency that could lead to crashes. Closes #2422267.

This commit is contained in:
Hisham Muhammad 2011-09-08 03:38:48 +00:00
parent 978019d34f
commit 5a8307a10b
1 changed files with 2 additions and 9 deletions

11
Panel.c
View File

@ -238,18 +238,11 @@ void Panel_setSelected(Panel* this, int selected) {
void Panel_draw(Panel* this, bool focus) {
assert (this != NULL);
int first, last;
int itemCount = Vector_size(this->items);
int scrollH = this->scrollH;
int y = this->y; int x = this->x;
first = this->scrollV;
if (this->h > itemCount) {
last = this->scrollV + itemCount;
move(y + last, x + 0);
} else {
last = MIN(itemCount, this->scrollV + this->h);
}
int first = this->scrollV;
int last = MIN(itemCount, this->scrollV + MIN(itemCount, this->h));
if (this->selected < first) {
first = this->selected;
this->scrollV = first;