Fix for multiple startup.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@16410 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2003-04-10 09:04:24 +00:00
parent b2c12040e5
commit aa2355943a
2 changed files with 38 additions and 35 deletions

View file

@ -2,6 +2,8 @@
* Source/GSServicesManager.m: on opening file, only activate for * Source/GSServicesManager.m: on opening file, only activate for
document based applications as suggested by Alexander. document based applications as suggested by Alexander.
* Source/NSWorkspace.m: ([_connectApplication:]) fix to handle
retries and timeouts correctly.
2003-04-10 01:53 Alexander Malmberg <alexander@malmberg.org> 2003-04-10 01:53 Alexander Malmberg <alexander@malmberg.org>

View file

@ -1908,10 +1908,9 @@ inFileViewerRootedAtPath: (NSString*)rootFullpath
NSString *host; NSString *host;
NSString *port; NSString *port;
NSDate *when = nil; NSDate *when = nil;
BOOL done = NO;
id app = nil; id app = nil;
while (done == NO) while (app == nil)
{ {
host = [[NSUserDefaults standardUserDefaults] stringForKey: @"NSHost"]; host = [[NSUserDefaults standardUserDefaults] stringForKey: @"NSHost"];
if (host == nil) if (host == nil)
@ -1944,19 +1943,25 @@ inFileViewerRootedAtPath: (NSString*)rootFullpath
} }
NS_ENDHANDLER NS_ENDHANDLER
done = YES;
if (app == nil) if (app == nil)
{ {
NSTask *task = [_launched objectForKey: appName]; NSTask *task = [_launched objectForKey: appName];
NSDate *limit;
if (task != nil && [task isRunning] == YES) if (task == nil || [task isRunning] == NO)
{ {
if (task != nil) // Not running
{
[_launched removeObjectForKey: appName];
}
break; // Need to launch the app
}
if (when == nil) if (when == nil)
{ {
when = [[NSDate alloc] init]; when = [[NSDate alloc] init];
done = NO;
} }
else if ([when timeIntervalSinceNow] > 5.0) else if ([when timeIntervalSinceNow] < -5.0)
{ {
int result; int result;
@ -1967,30 +1972,26 @@ inFileViewerRootedAtPath: (NSString*)rootFullpath
if (result == NSAlertDefaultReturn) if (result == NSAlertDefaultReturn)
{ {
done = YES; break; // Finished without app
} }
else if (result == NSAlertOtherReturn) else if (result == NSAlertOtherReturn)
{ {
done = NO; // Continue to wait for app startup.
} }
else else
{ {
[task terminate]; [task terminate];
[_launched removeObjectForKey: appName]; [_launched removeObjectForKey: appName];
done = YES; break; // Terminate hung app
} }
} }
if (done == NO)
{
NSDate *limit;
// Give it another 0.5 of a second to start up.
limit = [[NSDate alloc] initWithTimeIntervalSinceNow: 0.5]; limit = [[NSDate alloc] initWithTimeIntervalSinceNow: 0.5];
[[NSRunLoop currentRunLoop] runUntilDate: limit]; [[NSRunLoop currentRunLoop] runUntilDate: limit];
RELEASE(limit); RELEASE(limit);
} }
} }
}
}
TEST_RELEASE(when); TEST_RELEASE(when);
return app; return app;
} }