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:
Richard Frith-Macdonald 2003-04-10 09:04:24 +00:00
parent 0bdd1b569f
commit b2faf96893
2 changed files with 38 additions and 35 deletions

View file

@ -2,6 +2,8 @@
* Source/GSServicesManager.m: on opening file, only activate for
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>

View file

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