From ec2960c8a54cf1abd6239a644dc75bb63f2cbcb1 Mon Sep 17 00:00:00 2001 From: Nicola Pero Date: Fri, 17 Dec 1999 23:26:51 +0000 Subject: [PATCH] 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 --- Source/NSMatrix.m | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Source/NSMatrix.m b/Source/NSMatrix.m index 5d4963adf..4aed3f29c 100644 --- a/Source/NSMatrix.m +++ b/Source/NSMatrix.m @@ -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; }