aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2009-11-04 14:56:03 +0000
committerrowanbeentje <rowan@beent.je>2009-11-04 14:56:03 +0000
commit98938d5adb4e563a8be1ceb60d1fb4122276fbe0 (patch)
treea3de6cd684de26018649e9e515efff6572fc8e5b /Source
parent48d02b7080cadc507b1e7897c54ce2a8cf149acf (diff)
downloadsequelpro-98938d5adb4e563a8be1ceb60d1fb4122276fbe0.tar.gz
sequelpro-98938d5adb4e563a8be1ceb60d1fb4122276fbe0.tar.bz2
sequelpro-98938d5adb4e563a8be1ceb60d1fb4122276fbe0.zip
- Improve stability when flipping between tables with the content view selected
Diffstat (limited to 'Source')
-rw-r--r--Source/TableContent.h2
-rw-r--r--Source/TableContent.m23
2 files changed, 13 insertions, 12 deletions
diff --git a/Source/TableContent.h b/Source/TableContent.h
index b15fb957..7126be5c 100644
--- a/Source/TableContent.h
+++ b/Source/TableContent.h
@@ -61,7 +61,7 @@
NSString *selectedTable, *usedQuery;
NSMutableArray *tableValues, *dataColumns, *keys, *oldRow;
- NSUInteger tableRowsCount, previousTableRowsCount, tableColumnsCount;
+ NSUInteger tableRowsCount, previousTableRowsCount;
NSString *compareType;
NSNumber *sortCol;
BOOL isEditingRow, isEditingNewRow, isSavingRow, isDesc, setLimit;
diff --git a/Source/TableContent.m b/Source/TableContent.m
index ccc82e5e..29b92a73 100644
--- a/Source/TableContent.m
+++ b/Source/TableContent.m
@@ -62,7 +62,6 @@
tableRowsCount = 0;
previousTableRowsCount = 0;
dataColumns = [[NSMutableArray alloc] init];
- tableColumnsCount = 0;
oldRow = [[NSMutableArray alloc] init];
selectedTable = nil;
@@ -176,7 +175,6 @@
if (keys) [keys release], keys = nil;
// Reset data column store
- tableColumnsCount = 0;
[dataColumns removeAllObjects];
// If no table has been supplied, reset the view to a blank table and disabled elements.
@@ -340,7 +338,6 @@
// Add the column to the table
[tableContentView addTableColumn:theCol];
- tableColumnsCount++;
[theCol release];
}
@@ -577,6 +574,7 @@
NSMutableArray *newRow;
NSMutableArray *columnBlobStatuses = [[NSMutableArray alloc] init];
NSUInteger i;
+ NSUInteger dataColumnsCount = [dataColumns count];
float relativeTargetRowCount = 100.0/targetRowCount;
NSUInteger nextTableDisplayBoundary = 50;
@@ -589,7 +587,7 @@
BOOL prefsLoadBlobsAsNeeded = [prefs boolForKey:SPLoadBlobsAsNeeded];
// Build up an array of which columns are blobs for faster iteration
- for ( i = 0; i < tableColumnsCount ; i++ ) {
+ for ( i = 0; i < dataColumnsCount ; i++ ) {
[columnBlobStatuses addObject:[NSNumber numberWithBool:[tableDataInstance columnIsBlobOrText:[NSArrayObjectAtIndex(dataColumns, i) objectForKey:@"name"] ]]];
}
@@ -608,7 +606,7 @@
// Alter the values for hidden blob and text fields if appropriate
if ( prefsLoadBlobsAsNeeded ) {
newRow = NSArrayObjectAtIndex(tableValues, rowsProcessed);
- for ( i = 0 ; i < tableColumnsCount ; i++ ) {
+ for ( i = 0 ; i < dataColumnsCount ; i++ ) {
if ( [NSArrayObjectAtIndex(columnBlobStatuses, i) boolValue] ) {
NSMutableArrayReplaceObject(newRow, i, [SPNotLoaded notLoaded]);
}
@@ -2376,9 +2374,11 @@
// thread, an index higher than the available rows/columns may be requested. Return "..." to indicate loading in these
// cases - when the load completes all table data will be redrawn.
int columnIndex = [[aTableColumn identifier] intValue];
- if (rowIndex >= tableRowsCount || columnIndex >= tableColumnsCount) return @"...";
+ if (rowIndex >= tableRowsCount) return @"...";
+ NSMutableArray *rowData = NSArrayObjectAtIndex(tableValues, rowIndex);
+ if (columnIndex >= [rowData count]) return @"...";
- id theValue = NSArrayObjectAtIndex(NSArrayObjectAtIndex(tableValues, rowIndex), columnIndex);
+ id theValue = NSArrayObjectAtIndex(rowData, columnIndex);
if ([theValue isNSNull])
return [prefs objectForKey:SPNullValue];
@@ -2403,17 +2403,18 @@
// thread, an index higher than the available rows/columns may be requested. Return gray to indicate loading in these
// cases - when the load completes all table data will be redrawn.
int columnIndex = [[aTableColumn identifier] intValue];
- if (rowIndex >= tableRowsCount || columnIndex >= tableColumnsCount) {
+ if (rowIndex >= tableRowsCount) {
[cell setTextColor:[NSColor lightGrayColor]];
return;
}
-
- id theValue = NSArrayObjectAtIndex(NSArrayObjectAtIndex(tableValues, rowIndex), columnIndex);
- if (!theValue) {
+ NSMutableArray *rowData = NSArrayObjectAtIndex(tableValues, rowIndex);
+ if (columnIndex >= [rowData count]) {
[cell setTextColor:[NSColor lightGrayColor]];
return;
}
+ id theValue = NSArrayObjectAtIndex(rowData, columnIndex);
+
// If user wants to edit 'cell' set text color to black and return to avoid
// writing in gray if value was NULL
if ( [aTableView editedColumn] == [[aTableColumn identifier] intValue] && [aTableView editedRow] == rowIndex) {