Fix mouse click on empty matrix so it does not crash

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@5569 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Nicola Pero 1999-12-17 23:26:51 +00:00
parent fcb9c37b09
commit ec2960c8a5

View file

@ -669,6 +669,7 @@ static SEL getSel = @selector(objectAtIndex:);
BOOL betweenCols;
BOOL beyondRows;
BOOL beyondCols;
BOOL nullMatrix = NO;
int approxRow = point.y / (cellSize.height + intercell.height);
float approxRowsHeight = approxRow * (cellSize.height + intercell.height);
int approxCol = point.x / (cellSize.width + intercell.width);
@ -693,6 +694,11 @@ static SEL getSel = @selector(objectAtIndex:);
approxRow = 0;
else if (approxRow >= numRows)
approxRow = numRows - 1;
if (numRows == 0)
{
nullMatrix = YES;
approxRow = 0;
}
*row = approxRow;
}
@ -702,10 +708,15 @@ static SEL getSel = @selector(objectAtIndex:);
approxCol = 0;
else if (approxCol >= numCols)
approxCol = numCols - 1;
if (numCols == 0)
{
nullMatrix = YES;
approxCol = 0;
}
*column = approxCol;
}
if (beyondRows || betweenRows || beyondCols || betweenCols)
if (beyondRows || betweenRows || beyondCols || betweenCols || nullMatrix)
{
return NO;
}