aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPAppController.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2012-05-03 12:05:01 +0000
committerstuconnolly <stuart02@gmail.com>2012-05-03 12:05:01 +0000
commit83fa503079f7a049ffab9747b0360046474f3253 (patch)
tree028d0a92e558ba42e796847ab0f68d6e3037fb50 /Source/SPAppController.m
parent0d3af5fe7631325e8a892011f0595c76b1ebd49a (diff)
downloadsequelpro-83fa503079f7a049ffab9747b0360046474f3253.tar.gz
sequelpro-83fa503079f7a049ffab9747b0360046474f3253.tar.bz2
sequelpro-83fa503079f7a049ffab9747b0360046474f3253.zip
Add support for saving the state of the connection favorites outline view.
Diffstat (limited to 'Source/SPAppController.m')
-rw-r--r--Source/SPAppController.m49
1 files changed, 31 insertions, 18 deletions
diff --git a/Source/SPAppController.m b/Source/SPAppController.m
index da25b07f..4d3cc92b 100644
--- a/Source/SPAppController.m
+++ b/Source/SPAppController.m
@@ -38,12 +38,12 @@
#import "SPAlertSheets.h"
#import "SPChooseMenuItemDialog.h"
#import "SPCustomQuery.h"
+#import "SPFavoritesController.h"
+#import "SPEditorTokens.h"
#import <PSMTabBar/PSMTabBarControl.h>
#import <Sparkle/Sparkle.h>
-#import "SPEditorTokens.h"
-
#pragma mark lex init
/*
@@ -2227,21 +2227,27 @@ YY_BUFFER_STATE yy_scan_string (const char *);
}
/**
- * If Sequel Pro is terminating kill all running BASH scripts and release all HTML output controller
+ * If Sequel Pro is terminating kill all running BASH scripts and release all HTML output controller.
+ *
+ * TODO: Remove a lot of this duplicate code.
*/
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
{
-
- if(lastBundleBlobFilesDirectory != nil)
+ if (lastBundleBlobFilesDirectory != nil) {
[[NSFileManager defaultManager] removeItemAtPath:lastBundleBlobFilesDirectory error:nil];
+ }
// Kill all registered BASH commands
- for (NSWindow *aWindow in [NSApp orderedWindows]) {
- if([[aWindow windowController] isMemberOfClass:[SPWindowController class]]) {
- for(SPDatabaseDocument *doc in [[aWindow windowController] documents]) {
- for(NSDictionary* cmd in [doc runningActivities]) {
+ for (NSWindow *aWindow in [NSApp orderedWindows])
+ {
+ if ([[aWindow windowController] isMemberOfClass:[SPWindowController class]]) {
+ for (SPDatabaseDocument *doc in [[aWindow windowController] documents])
+ {
+ 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];
@@ -2251,9 +2257,12 @@ YY_BUFFER_STATE yy_scan_string (const char *);
}
}
}
- for(NSDictionary* cmd in [self runningActivities]) {
+
+ for (NSDictionary* cmd in [self 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];
@@ -2261,9 +2270,13 @@ YY_BUFFER_STATE yy_scan_string (const char *);
[killTask release];
}
- for(id c in bundleHTMLOutputController) {
+ for (id c in bundleHTMLOutputController)
+ {
[c release];
}
+
+ // Make sure we save any changes made to the connection outline view's state
+ [[SPFavoritesController sharedFavoritesController] saveFavorites];
return YES;
@@ -2278,13 +2291,13 @@ YY_BUFFER_STATE yy_scan_string (const char *);
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
- if(bundleItems) [bundleItems release];
- if(bundleUsedScopes) [bundleUsedScopes release];
- if(bundleHTMLOutputController) [bundleHTMLOutputController release];
- if(bundleCategories) [bundleCategories release];
- if(bundleTriggers) [bundleTriggers release];
- if(bundleKeyEquivalents) [bundleKeyEquivalents release];
- if(installedBundleUUIDs) [installedBundleUUIDs release];
+ if (bundleItems) [bundleItems release];
+ if (bundleUsedScopes) [bundleUsedScopes release];
+ if (bundleHTMLOutputController) [bundleHTMLOutputController release];
+ if (bundleCategories) [bundleCategories release];
+ if (bundleTriggers) [bundleTriggers release];
+ if (bundleKeyEquivalents) [bundleKeyEquivalents release];
+ if (installedBundleUUIDs) [installedBundleUUIDs release];
if (runningActivitiesArray) [runningActivitiesArray release];
[prefsController release], prefsController = nil;