aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPNavigatorController.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-03-31 13:38:33 +0000
committerBibiko <bibiko@eva.mpg.de>2010-03-31 13:38:33 +0000
commit6ab16708e84f0da9dbc26821c88e0c277d71c58e (patch)
treeb2c0f732c3285e087622aa19b5ee46b775caa92f /Source/SPNavigatorController.m
parent4960324c8ec2b830ad4daf8ca313de82b2dc2b2c (diff)
downloadsequelpro-6ab16708e84f0da9dbc26821c88e0c277d71c58e.tar.gz
sequelpro-6ab16708e84f0da9dbc26821c88e0c277d71c58e.tar.bz2
sequelpro-6ab16708e84f0da9dbc26821c88e0c277d71c58e.zip
• querying for db structure is queued for the same connection to avoid 'overlapping' access to global variables
• after querying db structure write back data on main thread • completion list displays animated sync images if connection is just querying db structure data • fixed some minor issue for completion list • make sure that if last window of a connection is closed all relevant data will be removed from global variables Note: please test!
Diffstat (limited to 'Source/SPNavigatorController.m')
-rw-r--r--Source/SPNavigatorController.m64
1 files changed, 34 insertions, 30 deletions
diff --git a/Source/SPNavigatorController.m b/Source/SPNavigatorController.m
index 439b4d5c..0bb723ba 100644
--- a/Source/SPNavigatorController.m
+++ b/Source/SPNavigatorController.m
@@ -70,7 +70,7 @@ static SPNavigatorController *sharedNavigatorController = nil;
expandStatus1 = [[NSMutableDictionary alloc] init];
expandStatus2 = [[NSMutableDictionary alloc] init];
infoArray = [[NSMutableArray alloc] init];
- updatingConnections = [[NSMutableSet alloc] initWithCapacity:1];
+ updatingConnections = [[NSMutableArray alloc] init];
selectedKey1 = @"";
selectedKey2 = @"";
ignoreUpdate = NO;
@@ -143,9 +143,6 @@ static SPNavigatorController *sharedNavigatorController = nil;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateNavigator:)
name:@"SPDBStructureWasUpdated" object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(isUpdatingNavigator:)
- name:@"SPDBStructureIsUpdating" object:nil];
-
}
- (NSString *)windowFrameAutosaveName
@@ -349,12 +346,14 @@ static SPNavigatorController *sharedNavigatorController = nil;
[schemaData removeObjectForKey:connectionID];
if(allSchemaKeys)
[allSchemaKeys removeObjectForKey:connectionID];
-
- [outlineSchema1 reloadData];
- [outlineSchema2 reloadData];
- [self restoreSelectedItems];
- if(isFiltered)
- [self filterTree:self];
+
+ if([[self window] isVisible]) {
+ [outlineSchema1 reloadData];
+ [outlineSchema2 reloadData];
+ [self restoreSelectedItems];
+ if(isFiltered)
+ [self filterTree:self];
+ }
}
}
@@ -418,15 +417,6 @@ static SPNavigatorController *sharedNavigatorController = nil;
[self performSelectorOnMainThread:@selector(updateEntriesForConnection:) withObject:nil waitUntilDone:YES];
}
-- (void)isUpdatingNavigator:(NSNotification *)aNotification
-{
- // id object = [aNotification object];
- //
- // if([object isKindOfClass:[TableDocument class]])
- // [updatingConnections addObject:[object connectionID]];
-
-}
-
- (void)updateEntriesForConnection:(NSString*)connectionID
{
@@ -435,13 +425,16 @@ static SPNavigatorController *sharedNavigatorController = nil;
return;
}
- [self saveSelectedItems];
+ if([[self window] isVisible]) {
+ [self saveSelectedItems];
+ [infoArray removeAllObjects];
+ }
- [infoArray removeAllObjects];
+ id doc = nil;
if ([[[NSDocumentController sharedDocumentController] documents] count]) {
- id doc = [[NSDocumentController sharedDocumentController] currentDocument];
+ doc = [[NSDocumentController sharedDocumentController] currentDocument];
id theConnection = [doc valueForKeyPath:@"mySQLConnection"];
if(!theConnection || ![theConnection isConnected]) return;
@@ -449,7 +442,6 @@ static SPNavigatorController *sharedNavigatorController = nil;
NSString *connectionName = [doc connectionID];
if(!connectionName || [connectionName isEqualToString:@"_"] || (connectionID && ![connectionName isEqualToString:connectionID]) ) {
-// NSLog(@"navigator update skipped %@", connectionName);
return;
}
@@ -481,21 +473,27 @@ static SPNavigatorController *sharedNavigatorController = nil;
[allSchemaKeys setObject:[NSArray array] forKey:connectionName];
}
- [outlineSchema1 reloadData];
- [outlineSchema2 reloadData];
+ [updatingConnections removeObject:connectionName];
- [self restoreExpandStatus];
- [self restoreSelectedItems];
+ if([[self window] isVisible]) {
+ [outlineSchema1 reloadData];
+ [outlineSchema2 reloadData];
- [updatingConnections removeObject:connectionName];
+ [self restoreExpandStatus];
+ [self restoreSelectedItems];
+ }
}
- [self syncButtonAction:self];
+ if([[self window] isVisible])
+ [self syncButtonAction:self];
if(isFiltered && [[self window] isVisible])
[self filterTree:self];
-
+
+ [[NSNotificationCenter defaultCenter] postNotificationName:@"SPNavigatorStructureWasUpdated" object:doc];
+
+
}
- (BOOL)schemaPathExistsForConnection:(NSString*)connectionID andDatabase:(NSString*)dbname
@@ -575,6 +573,11 @@ static SPNavigatorController *sharedNavigatorController = nil;
return ([updatingConnections containsObject:connectionID]) ? YES : NO;
}
+- (BOOL)isUpdating
+{
+ return ([updatingConnections count]) ? YES : NO;
+}
+
#pragma mark -
#pragma mark IBActions
@@ -824,6 +827,7 @@ static SPNavigatorController *sharedNavigatorController = nil;
return [item objectAtIndex:index];
}
return nil;
+
}
- (BOOL)outlineView:(id)outlineView isItemExpandable:(id)item