diff options
author | Max <post@wickenrode.com> | 2017-04-18 01:25:42 +0200 |
---|---|---|
committer | Max <post@wickenrode.com> | 2017-04-18 01:25:42 +0200 |
commit | dfab0cd76c54ba3f78284a57c89a7585a6042a38 (patch) | |
tree | bb16a793ffcd9dc78c8e26e1cfeea7a1178c5226 /Source/SPCustomQuery.m | |
parent | e1b881b8f893803c4949a69055c4e8106562327d (diff) | |
download | sequelpro-dfab0cd76c54ba3f78284a57c89a7585a6042a38.tar.gz sequelpro-dfab0cd76c54ba3f78284a57c89a7585a6042a38.tar.bz2 sequelpro-dfab0cd76c54ba3f78284a57c89a7585a6042a38.zip |
Remove a superfluous ivar and the unholy intermingling of UI and data code it has caused (part of #2770)
Diffstat (limited to 'Source/SPCustomQuery.m')
-rw-r--r-- | Source/SPCustomQuery.m | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/Source/SPCustomQuery.m b/Source/SPCustomQuery.m index 38c593d1..3cbd6a4d 100644 --- a/Source/SPCustomQuery.m +++ b/Source/SPCustomQuery.m @@ -61,6 +61,7 @@ #import "SPAppController.h" #import "SPBundleHTMLOutputController.h" #endif +#import "SPFunctions.h" #import <pthread.h> #import <SPMySQL/SPMySQL.h> @@ -884,7 +885,7 @@ (long)totalAffectedRows ]; } - if(resultDataCount) { + if([resultData count]) { // we were running a query that returns a result set (ie. SELECT). // TODO: mysql_query() returns as soon as the first result row is found (which might be pretty soon when using indexes / not doing aggregations) // and that makes our query time measurement pretty useless (see #264) @@ -905,7 +906,7 @@ #endif // If no results were returned, redraw the empty table and post notifications before returning. - if ( !resultDataCount ) { + if ( ![resultData count] ) { [customQueryView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:YES]; // Notify any listeners that the query has completed @@ -931,8 +932,6 @@ return; } - [[customQueryView onMainThread] reloadData]; - // Restore the result view origin if appropriate if (!NSEqualRects(selectionViewportToRestore, NSZeroRect)) { @@ -976,12 +975,12 @@ */ - (void)updateResultStore:(SPMySQLStreamingResultStore *)theResultStore { - - // Remove all items from the table - resultDataCount = 0; - [customQueryView performSelectorOnMainThread:@selector(noteNumberOfRowsChanged) withObject:nil waitUntilDone:YES]; pthread_mutex_lock(&resultDataLock); - [resultData removeAllRows]; + // Remove all items from the table + SPMainQSync(^{ + [resultData removeAllRows]; + [customQueryView noteNumberOfRowsChanged]; + }); // Add the new store [resultData setDataStorage:theResultStore updatingExisting:NO]; @@ -994,11 +993,8 @@ [[self onMainThread] initQueryLoadTimer]; [resultData awaitDataDownloaded]; - - // If the final column autoresize wasn't performed, perform it - if (queryLoadLastRowCount < 200) [[self onMainThread] autosizeColumns]; - - [customQueryView performSelectorOnMainThread:@selector(noteNumberOfRowsChanged) withObject:nil waitUntilDone:NO]; + + // Any further UI updates are the responsibility of the timer callback } /** @@ -1488,8 +1484,8 @@ */ - (void) queryLoadUpdate:(NSTimer *)theTimer { - resultDataCount = [resultData count]; - + NSUInteger resultDataCount = [resultData count]; + if (queryLoadTimerTicksSinceLastUpdate < queryLoadInterfaceUpdateInterval) { queryLoadTimerTicksSinceLastUpdate++; return; @@ -1501,7 +1497,7 @@ // Check whether a table update is required, based on whether new rows are // available to display. - if (resultDataCount == (NSInteger)queryLoadLastRowCount) { + if (resultDataCount == queryLoadLastRowCount) { return; } @@ -1548,7 +1544,7 @@ */ - (NSUInteger)currentResultRowCount { - return resultDataCount; + return [resultData count]; } /** @@ -2077,7 +2073,7 @@ */ - (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView { - return (aTableView == customQueryView) ? (resultData == nil) ? 0 : resultDataCount : 0; + return (aTableView == customQueryView) ? (resultData == nil) ? 0 : [resultData count] : 0; } /** @@ -2102,7 +2098,7 @@ if (isWorking) { pthread_mutex_lock(&resultDataLock); - if (rowIndex < resultDataCount && columnIndex < [resultData columnCount]) { + if (SPIntS2U(rowIndex) < [resultData count] && columnIndex < [resultData columnCount]) { showCellAsGray = [resultData cellIsNullOrUnloadedAtRow:rowIndex column:columnIndex]; } else { showCellAsGray = YES; @@ -2403,7 +2399,7 @@ // cases. if (isWorking) { pthread_mutex_lock(&resultDataLock); - if (row < resultDataCount && (NSUInteger)[[aTableColumn identifier] integerValue] < [resultData columnCount]) { + if (SPIntS2U(row) < [resultData count] && (NSUInteger)[[aTableColumn identifier] integerValue] < [resultData columnCount]) { theValue = [[SPDataStorageObjectAtRowAndColumn(resultData, row, [[aTableColumn identifier] integerValue]) copy] autorelease]; } pthread_mutex_unlock(&resultDataLock); @@ -3769,7 +3765,6 @@ #endif // init tableView's data source - resultDataCount = 0; resultData = [[SPDataStorage alloc] init]; editedRow = -1; @@ -4022,7 +4017,7 @@ if (isWorking) { pthread_mutex_lock(&resultDataLock); - if (row < resultDataCount && column < [resultData columnCount]) { + if (SPIntS2U(row) < [resultData count] && column < [resultData columnCount]) { value = SPDataStoragePreviewAtRowAndColumn(resultData, row, column, 150); } |