diff options
author | rowanbeentje <rowan@beent.je> | 2012-06-23 00:11:30 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2012-06-23 00:11:30 +0000 |
commit | 7d06e2efcc6874ac0a605920fdd62ec8cc433602 (patch) | |
tree | 0d72154ab0243764a60c731a26c9b790d59a0581 /Source/SPAppController.m | |
parent | bc51d59ca9a5ec8a741eef8142d3224a02461a5a (diff) | |
download | sequelpro-7d06e2efcc6874ac0a605920fdd62ec8cc433602.tar.gz sequelpro-7d06e2efcc6874ac0a605920fdd62ec8cc433602.tar.bz2 sequelpro-7d06e2efcc6874ac0a605920fdd62ec8cc433602.zip |
Further improvements to further address Issue #1332:
- Ensure that favourites are saved synchronously on exit to avoid background threads being killed
- Improve logging on favourite rename error
- Only save favourites on exit if a connection window is open
Diffstat (limited to 'Source/SPAppController.m')
-rw-r--r-- | Source/SPAppController.m | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/Source/SPAppController.m b/Source/SPAppController.m index ed8fd400..ca5887c9 100644 --- a/Source/SPAppController.m +++ b/Source/SPAppController.m @@ -2236,27 +2236,37 @@ YY_BUFFER_STATE yy_scan_string (const char *); */ - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { + BOOL shouldSaveFavorites = NO; + if (lastBundleBlobFilesDirectory != nil) { [[NSFileManager defaultManager] removeItemAtPath:lastBundleBlobFilesDirectory error:nil]; } - // Kill all registered BASH commands + // Iterate through each open window for (NSWindow *aWindow in [NSApp orderedWindows]) { - if ([[aWindow windowController] isMemberOfClass:[SPWindowController class]]) { - for (SPDatabaseDocument *doc in [[aWindow windowController] documents]) + if (![[aWindow windowController] isMemberOfClass:[SPWindowController class]]) continue; + + // Iterate through each document in the window + for (SPDatabaseDocument *doc in [[aWindow windowController] documents]) + { + + // Kill any BASH commands which are currently active + for (NSDictionary* cmd in [doc runningActivities]) { - for (NSDictionary* cmd in [doc runningActivities]) - { - NSInteger pid = [[cmd objectForKey:@"pid"] intValue]; - NSTask *killTask = [[NSTask alloc] init]; - - [killTask setLaunchPath:@"/bin/sh"]; - [killTask setArguments:[NSArray arrayWithObjects:@"-c", [NSString stringWithFormat:@"kill -9 -%ld", pid], nil]]; - [killTask launch]; - [killTask waitUntilExit]; - [killTask release]; - } + NSInteger pid = [[cmd objectForKey:@"pid"] intValue]; + NSTask *killTask = [[NSTask alloc] init]; + + [killTask setLaunchPath:@"/bin/sh"]; + [killTask setArguments:[NSArray arrayWithObjects:@"-c", [NSString stringWithFormat:@"kill -9 -%ld", pid], nil]]; + [killTask launch]; + [killTask waitUntilExit]; + [killTask release]; + } + + // If the connection view is active, mark the favourites for saving + if (![doc getConnection]) { + shouldSaveFavorites = YES; } } } @@ -2278,8 +2288,10 @@ YY_BUFFER_STATE yy_scan_string (const char *); [c release]; } - // Make sure we save any changes made to the connection outline view's state - [[SPFavoritesController sharedFavoritesController] saveFavorites]; + // If required, make sure we save any changes made to the connection outline view's state + if (shouldSaveFavorites) { + [[SPFavoritesController sharedFavoritesController] saveFavoritesSynchronously]; + } return YES; |