From 5b88ac6a6d0c02b1b51f295cf79e84b61c1f1bd5 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Wed, 8 Dec 2010 14:23:51 +0000 Subject: =?UTF-8?q?=E2=80=A2=20Bundle=20commands=20-=20improvemed=20error?= =?UTF-8?q?=20handling=20esp.=20if=20no=20front=20most=20connection=20wind?= =?UTF-8?q?ow=20can=20be=20found=20or=20it's=20not=20connected?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPStringAdditions.m | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'Source/SPStringAdditions.m') 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) -- cgit v1.2.3