Thursday, November 19, 2009

a bug in IO_Checklist

There was a bug in IO_Checklist.

To fix it, you need to change "for(int i=0;i<_len-1;i++)" to "for(int i=0;i<_len;i++)".


int IO_CheckList::edit(void){
int key;
bool done = false;
int x = 0;
int stat = 0;
while(!done){
stat = (int)_status[x];
key =io_flag(_format, IO_Field::getRow()+1+x, IO_Field::getCol()+1,&stat,_mode);
_status[x] = !!stat;
switch(key){
case DOWN_KEY:
if(x < _len-1){
x++;
}
else{
done = true;
}
break;
case UP_KEY:
if(x > 0){
x--;
}
else{
done = true;
}
break;
case ' ':

if(_mode == Radio){
for(int i=0;i<_len;i++){
if(i!=x && _status[i]){
_status[i] = false;
io_displayflag(_format, IO_Field::getRow()+1+i,
IO_Field::getCol()+1,0);
}
}
}
break;
default:
done = true;
}
}
return key;
}

No comments:

Post a Comment