Permalink
Browse files

Fix hang when there is only one row or column.

Fix issue where newly-added columns and rows would be cut off if they were added while the view was scrolled away from (0,0)
  • Loading branch information...
mattball committed Dec 10, 2009
1 parent 7a3cc74 commit 2711d14369b947ae218986ed75e3c4f0bc8f9c17
Showing with 6 additions and 6 deletions.
  1. +2 −2 MBTableGrid.m
  2. +2 −2 MBTableGridContentView.m
  3. +2 −2 MBTableGridController.m
View
@@ -831,9 +831,9 @@ - (void)reloadData
// Update the content view's size
NSUInteger lastColumn = [self numberOfColumns]-1;
NSUInteger lastRow = [self numberOfRows]-1;
- NSRect bottomRightCellFrame = [self frameOfCellAtColumn:lastColumn row:lastRow];
+ NSRect bottomRightCellFrame = [contentView frameOfCellAtColumn:lastColumn row:lastRow];
- NSRect contentRect = NSMakeRect([contentView frame].origin.x, [contentView frame].origin.y, NSMaxX(bottomRightCellFrame)-[contentScrollView frame].origin.x, NSMaxY(bottomRightCellFrame)-[contentScrollView frame].origin.y);
+ NSRect contentRect = NSMakeRect([contentView frame].origin.x, [contentView frame].origin.y, NSMaxX(bottomRightCellFrame), NSMaxY(bottomRightCellFrame));
[contentView setFrameSize:contentRect.size];
// Update the column header view's size
View
@@ -92,9 +92,9 @@ - (void)drawRect:(NSRect)rect
NSUInteger numberOfRows = [[self tableGrid] numberOfRows];
NSUInteger firstColumn = NSNotFound;
- NSUInteger lastColumn = NSNotFound;
+ NSUInteger lastColumn = numberOfColumns - 1;
NSUInteger firstRow = NSNotFound;
- NSUInteger lastRow = NSNotFound;
+ NSUInteger lastRow = numberOfRows - 1;
// Find the columns to draw
NSUInteger column = 0;
View
@@ -35,14 +35,14 @@ - (void)awakeFromNib
{
columns = [[NSMutableArray alloc] initWithCapacity:500];
- // Add 5 columns
+ // Add 10 columns
int i = 0;
while (i < 10) {
[self addColumn:self];
i++;
}
- // Add 10 rows
+ // Add 100 rows
int j = 0;
while (j < 100) {
[self addRow:self];

0 comments on commit 2711d14

Please sign in to comment.