diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/TableContent.m | 2 | ||||
-rw-r--r-- | Source/TablesList.m | 29 |
2 files changed, 17 insertions, 14 deletions
diff --git a/Source/TableContent.m b/Source/TableContent.m index bcaed509..9d5268c8 100644 --- a/Source/TableContent.m +++ b/Source/TableContent.m @@ -410,7 +410,7 @@ } // Restore first responder - [tableWindow makeFirstResponder:currentFirstResponder]; + [tableWindow performSelectorOnMainThread:@selector(makeFirstResponder:) withObject:currentFirstResponder waitUntilDone:NO]; // Enable or disable the limit fields according to preference setting if ( [prefs boolForKey:SPLimitResults] ) { diff --git a/Source/TablesList.m b/Source/TablesList.m index eabf062f..de1ce991 100644 --- a/Source/TablesList.m +++ b/Source/TablesList.m @@ -721,6 +721,7 @@ - (void) updateSelectionTask { NSAutoreleasePool *selectionChangePool = [[NSAutoreleasePool alloc] init]; + NSString *tableEncoding = nil; // Update the selected table name and type if (selectedTableName) [selectedTableName release]; @@ -739,22 +740,12 @@ // Reset the table information caches [tableDataInstance resetAllData]; - if (selectedTableType == SP_TABLETYPE_TABLE) { - [tableDataInstance updateInformationForCurrentTable]; - } else if (selectedTableType == SP_TABLETYPE_VIEW) { - [tableDataInstance updateInformationForCurrentView]; - } - - // Notify listeners of the table change now that the state is fully set up. - [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:SPTableChangedNotification object:tableDocumentInstance]; - - [separatorTableMenuItem setHidden:NO]; - [separatorTableContextMenuItem setHidden:NO]; + // Check the encoding if appropriate to determine if an encoding change and reset is required if( selectedTableType == SP_TABLETYPE_VIEW || selectedTableType == SP_TABLETYPE_TABLE) { // tableEncoding == nil indicates that there was an error while retrieving table data - NSString *tableEncoding = [tableDataInstance tableEncoding]; + tableEncoding = [tableDataInstance tableEncoding]; // If encoding is set to Autodetect, update the connection character set encoding // based on the newly selected table's encoding - but only if it differs from the current encoding. @@ -762,9 +753,21 @@ if (tableEncoding != nil && ![tableEncoding isEqualToString:[tableDocumentInstance connectionEncoding]]) { [tableDocumentInstance setConnectionEncoding:tableEncoding reloadingViews:NO]; [tableDataInstance resetAllData]; + tableEncoding = [tableDataInstance tableEncoding]; } } - + } + + // Ensure status information is cached on the working thread + [tableDataInstance updateStatusInformationForCurrentTable]; + + // Notify listeners of the table change now that the state is fully set up. + [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:SPTableChangedNotification object:tableDocumentInstance]; + + [separatorTableMenuItem setHidden:NO]; + [separatorTableContextMenuItem setHidden:NO]; + + if( selectedTableType == SP_TABLETYPE_VIEW || selectedTableType == SP_TABLETYPE_TABLE) { if ( [tabView indexOfTabViewItem:[tabView selectedTabViewItem]] == 0 ) { [tableSourceInstance loadTable:selectedTableName]; structureLoaded = YES; |