aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2009-03-25 01:30:03 +0000
committerrowanbeentje <rowan@beent.je>2009-03-25 01:30:03 +0000
commitaa3dca31f0509f304df0399b9b7e06a51739bc97 (patch)
treeb949c2b28f041bab12f0bced76964c9af99d2036
parenta6a85c4ba06e98b6e14e34c463e3e46711eb506c (diff)
downloadsequelpro-aa3dca31f0509f304df0399b9b7e06a51739bc97.tar.gz
sequelpro-aa3dca31f0509f304df0399b9b7e06a51739bc97.tar.bz2
sequelpro-aa3dca31f0509f304df0399b9b7e06a51739bc97.zip
- Refactor custom query results redrawing code and reset view position to avoid out-of-range assertions when switching from a larger dataset to a smaller dataset; this fixes Issue #189
-rw-r--r--Source/CustomQuery.m40
1 files changed, 17 insertions, 23 deletions
diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m
index a955bec3..e8c7af53 100644
--- a/Source/CustomQuery.m
+++ b/Source/CustomQuery.m
@@ -278,6 +278,17 @@ sets the tableView columns corresponding to the mysql-result
// Notify listeners that a query has started
[[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryWillBePerformed" object:self];
+ // Reset the current table view as necessary to avoid redraw and reload issues.
+ // Restore the view position to the top left to be within the results for all datasets.
+ [customQueryView scrollRowToVisible:0];
+ [customQueryView scrollColumnToVisible:0];
+
+ // Remove all the columns
+ theColumns = [customQueryView tableColumns];
+ while ([theColumns count]) {
+ [customQueryView removeTableColumn:[theColumns objectAtIndex:0]];
+ }
+
// Perform the supplied queries in series
for ( i = 0 ; i < [queries count] ; i++ ) {
@@ -373,25 +384,16 @@ sets the tableView columns corresponding to the mysql-result
}
}
-
+
+
+ // If no results were returned, redraw the empty table and post notifications before returning.
if ( !theResult || ![theResult numOfRows] ) {
-//no rows in result
- //free tableView
- theColumns = [customQueryView tableColumns];
- while ([theColumns count]) {
- [customQueryView removeTableColumn:[theColumns objectAtIndex:0]];
- }
-// theCol = [[NSTableColumn alloc] initWithIdentifier:@""];
-// [[theCol headerCell] setStringValue:@""];
-// [customQueryView addTableColumn:theCol];
-// [customQueryView sizeLastColumnToFit];
[customQueryView reloadData];
-// [theCol release];
- //query finished
+ // Notify any listeners that the query has completed
[[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:self];
- // Query finished Growl notification
+ // Perform the Growl notification for query completion
[[SPGrowlController sharedGrowlController] notifyWithTitle:@"Query Finished"
description:[NSString stringWithFormat:NSLocalizedString(@"%@",@"description for query finished growl notification"), [errorText stringValue]]
notificationName:@"Query Finished"];
@@ -399,16 +401,8 @@ sets the tableView columns corresponding to the mysql-result
return;
}
-//set columns
-//remove all columns
- theColumns = [customQueryView tableColumns];
-// i=0;
- while ([theColumns count]) {
- [customQueryView removeTableColumn:[theColumns objectAtIndex:0]];
-// i++;
- }
-//add columns, corresponding to the query result
+ // Otherwise add columns corresponding to the query result
theColumns = [theResult fetchFieldNames];
for ( i = 0 ; i < [theResult numOfFields] ; i++) {
theCol = [[NSTableColumn alloc] initWithIdentifier:[NSNumber numberWithInt:i]];