aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2012-03-21 01:31:09 +0000
committerrowanbeentje <rowan@beent.je>2012-03-21 01:31:09 +0000
commit3916b4227d1e02942504e13a2d36b3e6f57670bb (patch)
tree392fc9f3ed09c8cbe5719d04e45303ae2ff190b7
parent566aa46a231fd45a4c373a8122ab2bb6aa39ced6 (diff)
downloadsequelpro-3916b4227d1e02942504e13a2d36b3e6f57670bb.tar.gz
sequelpro-3916b4227d1e02942504e13a2d36b3e6f57670bb.tar.bz2
sequelpro-3916b4227d1e02942504e13a2d36b3e6f57670bb.zip
- Fix a possible race condition exception when switching between tables when th structure view was active, the collation column was visible, and fields had custom collations
-rw-r--r--Source/SPTableStructure.m10
-rw-r--r--Source/SPTableStructureDelegate.m2
2 files changed, 8 insertions, 4 deletions
diff --git a/Source/SPTableStructure.m b/Source/SPTableStructure.m
index 085cc558..c6f20ded 100644
--- a/Source/SPTableStructure.m
+++ b/Source/SPTableStructure.m
@@ -292,15 +292,19 @@
// Set up the encoding PopUpButtonCell
NSArray *encodings = [databaseDataInstance getDatabaseCharacterSetEncodings];
if ([encodings count]) {
- [[encodingPopupCell onMainThread] removeAllItems];
- [[encodingPopupCell onMainThread] addItemWithTitle:@""];
// Populate encoding popup button
+ NSMutableArray *encodingTitles = [[NSMutableArray alloc] initWithCapacity:[encodings count]+1];
+ [encodingTitles addObject:@""];
for (NSDictionary *encoding in encodings)
- [[encodingPopupCell onMainThread] addItemWithTitle:(![encoding objectForKey:@"DESCRIPTION"]) ? [encoding objectForKey:@"CHARACTER_SET_NAME"] : [NSString stringWithFormat:@"%@ (%@)", [encoding objectForKey:@"DESCRIPTION"], [encoding objectForKey:@"CHARACTER_SET_NAME"]]];
+ [encodingTitles addObject:(![encoding objectForKey:@"DESCRIPTION"]) ? [encoding objectForKey:@"CHARACTER_SET_NAME"] : [NSString stringWithFormat:@"%@ (%@)", [encoding objectForKey:@"DESCRIPTION"], [encoding objectForKey:@"CHARACTER_SET_NAME"]]];
+ [[encodingPopupCell onMainThread] removeAllItems];
+ [[encodingPopupCell onMainThread] addItemsWithTitles:encodingTitles];
+ [encodingTitles release];
}
else {
+ [[encodingPopupCell onMainThread] removeAllItems];
[[encodingPopupCell onMainThread] addItemWithTitle:NSLocalizedString(@"Not available", @"not available label")];
}
diff --git a/Source/SPTableStructureDelegate.m b/Source/SPTableStructureDelegate.m
index 6493e850..d0bbbf75 100644
--- a/Source/SPTableStructureDelegate.m
+++ b/Source/SPTableStructureDelegate.m
@@ -49,7 +49,7 @@
if([[tableColumn identifier] isEqualToString:@"collation"]) {
NSInteger idx = 0;
- if((idx = [[NSArrayObjectAtIndex(tableFields,rowIndex) objectForKey:@"encoding"] integerValue]) > 0) {
+ if((idx = [[NSArrayObjectAtIndex(tableFields,rowIndex) objectForKey:@"encoding"] integerValue]) > 0 && idx < [encodingPopupCell numberOfItems]) {
NSString *enc = [[encodingPopupCell itemAtIndex:idx] title];
NSInteger start = [enc rangeOfString:@"("].location+1;
NSInteger end = [enc length] - start - 1;