mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 13:10:38 +00:00
More graceful startup.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3553 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
4a6b8325ac
commit
c8b326d53f
3 changed files with 97 additions and 25 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
Sat Jan 9 6:10:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* Source/NSApplication.m: ([-run]) reorganize so that the app can be
|
||||
terminated before entry to the run loop (in finishLaunching) and to
|
||||
make the event loop slightly more efficient.
|
||||
* Source/GSServicesManager.m: ([-registerAsServiceProvider:]) added
|
||||
checks to raise alert panel to let the application continue when it
|
||||
conflicts with an already running application or when the DO system
|
||||
is not working.
|
||||
|
||||
Fri Jan 8 14:25:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* Images/GNUmakefile: Added common_WMClose.tiff and
|
||||
|
|
|
@ -132,6 +132,9 @@ NSRegisterServicesProvider(id provider, NSString *name)
|
|||
name: NSConnectionDidDieNotification
|
||||
object: listenerConnection];
|
||||
}
|
||||
else
|
||||
[NSException raise: NSGenericException
|
||||
format: @"unable to register %@", name];
|
||||
}
|
||||
ASSIGN(servicesProvider, provider);
|
||||
}
|
||||
|
@ -738,15 +741,65 @@ static NSString *disabledName = @".GNUstepDisabled";
|
|||
*/
|
||||
- (void) registerAsServiceProvider
|
||||
{
|
||||
NSString *appName;
|
||||
NSString *appName;
|
||||
BOOL registered;
|
||||
|
||||
appName = [[[NSProcessInfo processInfo] processName] lastPathComponent];
|
||||
NS_DURING
|
||||
NSRegisterServicesProvider(self, appName);
|
||||
{
|
||||
NSRegisterServicesProvider(self, appName);
|
||||
registered = YES;
|
||||
}
|
||||
NS_HANDLER
|
||||
NSLog(@"Warning: Could not access services due to exception: %@\n",
|
||||
[localException reason]);
|
||||
registered = NO;
|
||||
NS_ENDHANDLER
|
||||
|
||||
if (registered == NO)
|
||||
{
|
||||
int result = NSRunAlertPanel(appName,
|
||||
@"Application may already be running with this name",
|
||||
@"Continue", @"Abort", @"Rename");
|
||||
|
||||
if (result == NSAlertDefaultReturn || result == NSAlertOtherReturn)
|
||||
{
|
||||
if (result == NSAlertOtherReturn)
|
||||
appName = [NSString stringWithFormat: @"%@_%d",
|
||||
appName, (int)getpid()];
|
||||
[[NSPortNameServer defaultPortNameServer] removePortForName: appName];
|
||||
|
||||
NS_DURING
|
||||
{
|
||||
NSRegisterServicesProvider(self, appName);
|
||||
registered = YES;
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
registered = NO;
|
||||
NSLog(@"Warning: Could not register application due to "
|
||||
@"exception: %@\n", [localException reason]);
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
|
||||
/*
|
||||
* Something is seriously wrong - we can't talk to the
|
||||
* nameserver, so all interaction with the workspace manager
|
||||
* and/or other applications will fail.
|
||||
* Give the user a chance to keep on going anyway.
|
||||
*/
|
||||
if (registered == NO)
|
||||
{
|
||||
result = NSRunAlertPanel(appName,
|
||||
@"Unable to register application with ANY name",
|
||||
@"Abort", @"Continue", nil);
|
||||
|
||||
if (result == NSAlertDefaultReturn)
|
||||
registered = YES;
|
||||
}
|
||||
}
|
||||
|
||||
if (registered == NO)
|
||||
[[NSApplication sharedApplication] terminate: self];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -272,38 +272,47 @@ NSString* mainModelFile;
|
|||
//
|
||||
- (void) run
|
||||
{
|
||||
NSEvent *e;
|
||||
NSAutoreleasePool* pool;
|
||||
NSEvent *e;
|
||||
Class arpClass = [NSAutoreleasePool class]; /* Cache the class */
|
||||
NSAutoreleasePool* pool;
|
||||
|
||||
NSDebugLog(@"NSApplication -run\n");
|
||||
NSDebugLog(@"NSApplication -run\n");
|
||||
|
||||
[self finishLaunching];
|
||||
/*
|
||||
* Set this flag here in case the application is actually terminated
|
||||
* inside -finishLaunching.
|
||||
*/
|
||||
app_should_quit = NO;
|
||||
|
||||
app_should_quit = NO;
|
||||
app_is_running = YES;
|
||||
[self finishLaunching];
|
||||
|
||||
do {
|
||||
pool = [NSAutoreleasePool new];
|
||||
app_is_running = YES;
|
||||
|
||||
e = [self nextEventMatchingMask:NSAnyEventMask
|
||||
while (app_should_quit == NO)
|
||||
{
|
||||
pool = [arpClass new];
|
||||
|
||||
e = [self nextEventMatchingMask:NSAnyEventMask
|
||||
untilDate:[NSDate distantFuture]
|
||||
inMode:NSDefaultRunLoopMode
|
||||
dequeue:YES];
|
||||
if (e)
|
||||
[self sendEvent: e];
|
||||
if (e)
|
||||
[self sendEvent: e];
|
||||
|
||||
[listener updateServicesMenu]; // update (en/disable) the
|
||||
// services menu's items
|
||||
[main_menu update];
|
||||
// update (en/disable) the
|
||||
// services menu's items
|
||||
[listener updateServicesMenu];
|
||||
[main_menu update];
|
||||
|
||||
if (windows_need_update) // send an update message
|
||||
[self updateWindows]; // to all visible windows
|
||||
// send an update message
|
||||
// to all visible windows
|
||||
if (windows_need_update)
|
||||
[self updateWindows];
|
||||
|
||||
[pool release];
|
||||
}
|
||||
while (!app_should_quit);
|
||||
[pool release];
|
||||
}
|
||||
|
||||
NSDebugLog(@"NSApplication end of run loop\n");
|
||||
NSDebugLog(@"NSApplication end of run loop\n");
|
||||
}
|
||||
|
||||
- (BOOL) isRunning
|
||||
|
@ -1621,7 +1630,7 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
|||
//
|
||||
- (void) terminate: (id)sender
|
||||
{
|
||||
if ([self applicationShouldTerminate:self])
|
||||
if ([self applicationShouldTerminate: self])
|
||||
{ // app should end run loop
|
||||
app_should_quit = YES;
|
||||
[event_queue addObject: null_event]; // add dummy event to queue
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue