diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-12-08 14:23:51 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-12-08 14:23:51 +0000 |
commit | 5b88ac6a6d0c02b1b51f295cf79e84b61c1f1bd5 (patch) | |
tree | 9f2d0fda7117fd3dfe2a799fed7f1788fc3e3a15 /Source/SPStringAdditions.m | |
parent | a6180b9b0c513d11e27c7f8f5801225fcbed315c (diff) | |
download | sequelpro-5b88ac6a6d0c02b1b51f295cf79e84b61c1f1bd5.tar.gz sequelpro-5b88ac6a6d0c02b1b51f295cf79e84b61c1f1bd5.tar.bz2 sequelpro-5b88ac6a6d0c02b1b51f295cf79e84b61c1f1bd5.zip |
• Bundle commands
- improvemed error handling esp. if no front most connection window can be found or it's not connected
Diffstat (limited to 'Source/SPStringAdditions.m')
-rw-r--r-- | Source/SPStringAdditions.m | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/Source/SPStringAdditions.m b/Source/SPStringAdditions.m index 3c875c77..97339201 100644 --- a/Source/SPStringAdditions.m +++ b/Source/SPStringAdditions.m @@ -533,23 +533,32 @@ // Create and set an unique process ID for each SPDatabaseDocument which has to passed // for each sequelpro:// scheme command as user to be able to identify the url scheme command. // Furthermore this id is used to communicate with the called command as file name. - [theEnv setObject:uuid forKey:@"SP_PROCESS_ID"]; id doc = nil; if([[[NSApp mainWindow] delegate] respondsToSelector:@selector(selectedTableDocument)]) doc = [[[NSApp mainWindow] delegate] selectedTableDocument]; + // Check if connected + if([[doc connectionID] isEqualToString:@"_"]) + doc = nil; else { for (NSWindow *aWindow in [NSApp orderedWindows]) { if([[[[aWindow windowController] class] description] isEqualToString:@"SPWindowController"]) { if([[[aWindow windowController] documents] count] && [[[[[[aWindow windowController] documents] objectAtIndex:0] class] description] isEqualToString:@"SPDatabaseDocument"]) { - doc = [[[aWindow windowController] documents] objectAtIndex:0]; + // Check if connected + if(![[[[[aWindow windowController] documents] objectAtIndex:0] connectionID] isEqualToString:@"_"]) + doc = [[[aWindow windowController] documents] objectAtIndex:0]; + else + doc = nil; } } if(doc) break; } } + if(doc != nil) { + [doc setProcessID:uuid]; + [theEnv setObject:uuid forKey:@"SP_PROCESS_ID"]; [theEnv setObject:[NSString stringWithFormat:@"%@%@", SPURLSchemeQueryInputPathHeader, uuid] forKey:SPBundleShellVariableQueryFile]; [theEnv setObject:[NSString stringWithFormat:@"%@%@", SPURLSchemeQueryResultPathHeader, uuid] forKey:SPBundleShellVariableQueryResultFile]; [theEnv setObject:[NSString stringWithFormat:@"%@%@", SPURLSchemeQueryResultStatusPathHeader, uuid] forKey:SPBundleShellVariableQueryResultStatusFile]; @@ -558,10 +567,11 @@ if([doc shellVariables]) [theEnv addEntriesFromDictionary:[doc shellVariables]]; - if(theEnv != nil && [theEnv count]) - [bashTask setEnvironment:theEnv]; } + if(theEnv != nil && [theEnv count]) + [bashTask setEnvironment:theEnv]; + if(path != nil) [bashTask setCurrentDirectoryPath:path]; else if([shellEnvironment objectForKey:SPBundleShellVariableBundlePath] && [fm fileExistsAtPath:[shellEnvironment objectForKey:SPBundleShellVariableBundlePath] isDirectory:&isDir] && isDir) |