diff options
author | rowanbeentje <rowan@beent.je> | 2009-11-22 15:00:00 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2009-11-22 15:00:00 +0000 |
commit | 68168615e8c35c2d5c6e08284dc1478376883d8d (patch) | |
tree | 25b99f9802ee3590e7f300329a3e1061e5bf45d5 /Source/TablesList.m | |
parent | de9ddc82c305f187d6ab8802641eba9f2c90f0c1 (diff) | |
download | sequelpro-68168615e8c35c2d5c6e08284dc1478376883d8d.tar.gz sequelpro-68168615e8c35c2d5c6e08284dc1478376883d8d.tar.bz2 sequelpro-68168615e8c35c2d5c6e08284dc1478376883d8d.zip |
- Improve upon r1560 by removing a couple of race conditions triggered on encoding changes, status requests, or blob/text lookups on slower connections
- Restore first responder in TableContent loads on the main thread to fix a potential crasher
Diffstat (limited to 'Source/TablesList.m')
-rw-r--r-- | Source/TablesList.m | 29 |
1 files changed, 16 insertions, 13 deletions
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; |