aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPTableStructure.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-09-22 14:42:40 +0000
committerBibiko <bibiko@eva.mpg.de>2010-09-22 14:42:40 +0000
commitf12e8dfc1453248b843efe9066570206c26bbdd6 (patch)
tree1dba57aa88976bb43e7fe09839989030c893a9a5 /Source/SPTableStructure.m
parent45243302a11f65b282059e03e3827f7b207b0fc7 (diff)
downloadsequelpro-f12e8dfc1453248b843efe9066570206c26bbdd6.tar.gz
sequelpro-f12e8dfc1453248b843efe9066570206c26bbdd6.tar.bz2
sequelpro-f12e8dfc1453248b843efe9066570206c26bbdd6.zip
• fixed issue836 by avoiding the fact that while selecting a new table the CREATE SYNTAX will be parsed twice under certain circumstances which led to this issue
- introduced a isWorking mechanism to SPTableData; while SPTableData is updating its cache (ie the CREATE SYNTAX is being parsed) each request for values will return nil or an empty array; the caller is responsible to decide what to do • various commenting stuff • various speed improvements
Diffstat (limited to 'Source/SPTableStructure.m')
-rw-r--r--Source/SPTableStructure.m33
1 files changed, 18 insertions, 15 deletions
diff --git a/Source/SPTableStructure.m b/Source/SPTableStructure.m
index 410a9bd3..f0556ba8 100644
--- a/Source/SPTableStructure.m
+++ b/Source/SPTableStructure.m
@@ -150,7 +150,6 @@
*/
- (void)loadTable:(NSString *)aTable
{
- NSMutableArray *theTableFields = [NSMutableArray array];
NSArray *theTableIndexes;
NSMutableDictionary *theTableEnumLists = [NSMutableDictionary dictionary];
NSInteger i;
@@ -164,6 +163,9 @@
return;
}
+ NSMutableArray *theTableFields = [[NSMutableArray alloc] init];
+ [theTableFields setArray:[NSArray array]];
+
// Make a mutable copy out of the cached [tableDataInstance columns] since we're adding infos
for(id col in [tableDataInstance columns])
[theTableFields addObject:[[col mutableCopy] autorelease]];
@@ -205,16 +207,15 @@
// Set up the encoding PopUpButtonCell
NSArray *encodings = [databaseDataInstance getDatabaseCharacterSetEncodings];
- if (([encodings count] > 0) && ([tableDataInstance tableEncoding])) {
+ if ([encodings count]) {
NSString *selectedTitle = @"";
[encodingPopupCell removeAllItems];
[encodingPopupCell addItemWithTitle:@""];
+
// Populate encoding popup button
for (NSDictionary *encoding in encodings)
- {
- NSString *menuItemTitle = (![encoding objectForKey:@"DESCRIPTION"]) ? [encoding objectForKey:@"CHARACTER_SET_NAME"] : [NSString stringWithFormat:@"%@ (%@)", [encoding objectForKey:@"DESCRIPTION"], [encoding objectForKey:@"CHARACTER_SET_NAME"]];
- [encodingPopupCell addItemWithTitle:menuItemTitle];
- }
+ [encodingPopupCell addItemWithTitle:(![encoding objectForKey:@"DESCRIPTION"]) ? [encoding objectForKey:@"CHARACTER_SET_NAME"] : [NSString stringWithFormat:@"%@ (%@)", [encoding objectForKey:@"DESCRIPTION"], [encoding objectForKey:@"CHARACTER_SET_NAME"]]];
+
}
else {
[encodingPopupCell addItemWithTitle:NSLocalizedString(@"Not available", @"not available label")];
@@ -296,6 +297,7 @@
// Send the query finished/work complete notification
[[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance];
+ [theTableFields release];
}
/**
@@ -330,10 +332,10 @@
[indexesController setTable:selectedTable];
// Reset the table store and display
+ [tableFields removeAllObjects];
[enumFields removeAllObjects];
[tableSourceView deselectAll:self];
[indexesTableView deselectAll:self];
- [tableFields removeAllObjects];
[addFieldButton setEnabled:NO];
[copyFieldButton setEnabled:NO];
[removeFieldButton setEnabled:NO];
@@ -1380,13 +1382,14 @@ returns a dictionary containing enum/set field names as key and possible values
if (rowIndex >= [tableFields count]) return @"...";
if([[tableColumn identifier] isEqualToString:@"collation"]) {
- if([[[tableFields objectAtIndex:rowIndex] objectForKey:@"encoding"] integerValue] > 0) {
- NSString *enc = [[encodingPopupCell itemAtIndex:[[[tableFields objectAtIndex:rowIndex] objectForKey:@"encoding"] integerValue]] title];
+ NSInteger idx = 0;
+ if((idx = [[NSArrayObjectAtIndex(tableFields,rowIndex) objectForKey:@"encoding"] integerValue]) > 0) {
+ NSString *enc = [[encodingPopupCell itemAtIndex:idx] title];
NSInteger start = [enc rangeOfString:@"("].location+1;
NSInteger end = [enc length] - start - 1;
collations = [databaseDataInstance getDatabaseCollationsForEncoding:[enc substringWithRange:NSMakeRange(start, end)]];
} else {
- if([tableDataInstance tableEncoding]) {
+ if([tableDataInstance tableEncoding] != nil) {
collations = [databaseDataInstance getDatabaseCollationsForEncoding:[tableDataInstance tableEncoding]];
} else {
collations = [NSArray array];
@@ -1403,7 +1406,7 @@ returns a dictionary containing enum/set field names as key and possible values
}
}
- return [[tableFields objectAtIndex:rowIndex] objectForKey:[tableColumn identifier]];
+ return [NSArrayObjectAtIndex(tableFields, rowIndex) objectForKey:[tableColumn identifier]];
}
- (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
@@ -1790,10 +1793,10 @@ would result in a position change.
} else {
// validate cell against current field type
- NSDictionary *theRow = [tableFields objectAtIndex:rowIndex];
+ NSDictionary *theRow = NSArrayObjectAtIndex(tableFields, rowIndex);
NSString *theRowType = @"";
- if([theRow objectForKey:@"type"])
- theRowType = [[[theRow objectForKey:@"type"] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString];
+ if(theRowType = [theRow objectForKey:@"type"])
+ theRowType = [[theRowType stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString];
// Only string fields allow encoding settings
if(([[aTableColumn identifier] isEqualToString:@"encoding"])) {
@@ -1874,7 +1877,7 @@ would result in a position change.
- (id)comboBoxCell:(NSComboBoxCell *)aComboBoxCell objectValueForItemAtIndex:(NSInteger)index
{
- return [typeSuggestions objectAtIndex:index];
+ return NSArrayObjectAtIndex(typeSuggestions, index);
}
- (NSInteger)numberOfItemsInComboBoxCell:(NSComboBoxCell *)aComboBoxCell