NSApplication bugfixes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@5514 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 1999-12-15 02:24:48 +00:00
parent 3b7a5e0770
commit 5212de5341
2 changed files with 48 additions and 42 deletions

View file

@ -9,6 +9,11 @@ Tue Dec 14 19:40:12 1999 Nicola Pero <n.pero@mi.flashnet.it>
to ([-initTextCell:]),([-initImageCell:]); redundancies to ([-initTextCell:]),([-initImageCell:]); redundancies
removed. removed.
Tue Dec 14 19:07:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/NSApplication.m: modal session fixes (and tidying) suggested
by georg@mondoshawan.unix.cslab.tuwien.ac.at
Tue Dec 14 16:51:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk> Tue Dec 14 16:51:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/NSWindow.m: ([-becomeKeyWindow]) Don't ask the backend to * Source/NSWindow.m: ([-becomeKeyWindow]) Don't ask the backend to

View file

@ -871,9 +871,10 @@ static NSCell* tileCell = nil;
- (void) abortModal - (void) abortModal
{ {
if (session == 0) if (session == 0)
[NSException raise: NSAbortModalException {
format: @"abortModal called while not in a modal session"]; [NSException raise: NSAbortModalException
format: @"abortModal called while not in a modal session"];
}
[NSException raise: NSAbortModalException format: @"abortModal"]; [NSException raise: NSAbortModalException format: @"abortModal"];
} }
@ -896,32 +897,34 @@ static NSCell* tileCell = nil;
NSModalSession tmp = session; NSModalSession tmp = session;
if (theSession == 0) if (theSession == 0)
[NSException raise: NSInvalidArgumentException {
format: @"null pointer passed to endModalSession: "]; [NSException raise: NSInvalidArgumentException
format: @"null pointer passed to endModalSession:"];
}
/* Remove this session from linked list of sessions. */ /* Remove this session from linked list of sessions. */
while (tmp && tmp != theSession) while (tmp != 0 && tmp != theSession)
tmp = tmp->previous; {
tmp = tmp->previous;
}
if (tmp == 0) if (tmp == 0)
[NSException raise: NSInvalidArgumentException {
format: @"unknown session passed to endModalSession: "]; [NSException raise: NSInvalidArgumentException
format: @"unknown session passed to endModalSession:"];
}
while (session != theSession) while (session != theSession)
{ {
tmp = session; tmp = session;
session = tmp->previous; session = tmp->previous;
NSZoneFree(NSDefaultMallocZone(), tmp); NSZoneFree(NSDefaultMallocZone(), tmp);
} }
session = session->previous; session = session->previous;
NSZoneFree(NSDefaultMallocZone(), session); NSZoneFree(NSDefaultMallocZone(), theSession);
} }
- (int) runModalForWindow: (NSWindow*)theWindow - (int) runModalForWindow: (NSWindow*)theWindow
{ {
static NSModalSession theSession; NSModalSession theSession = 0;
static int code; int code = NSRunContinuesResponse;
/* /*
* The NSWindow documentation says runModalForWindow centers panels. * The NSWindow documentation says runModalForWindow centers panels.
@ -930,7 +933,6 @@ static NSCell* tileCell = nil;
{ {
[theWindow center]; [theWindow center];
} }
[theWindow orderFrontRegardless]; [theWindow orderFrontRegardless];
if ([self isActive] == YES) if ([self isActive] == YES)
{ {
@ -944,9 +946,6 @@ static NSCell* tileCell = nil;
} }
} }
theSession = NULL;
code = NSRunContinuesResponse;
NS_DURING NS_DURING
{ {
theSession = [self beginModalSessionForWindow: theWindow]; theSession = [self beginModalSessionForWindow: theWindow];
@ -954,12 +953,11 @@ static NSCell* tileCell = nil;
{ {
code = [self runModalSession: theSession]; code = [self runModalSession: theSession];
} }
[self endModalSession: theSession]; [self endModalSession: theSession];
} }
NS_HANDLER NS_HANDLER
{ {
if (theSession) if (theSession != 0)
{ {
NSWindow *win_to_close = theSession->window; NSWindow *win_to_close = theSession->window;
@ -967,11 +965,12 @@ static NSCell* tileCell = nil;
[win_to_close close]; [win_to_close close];
} }
if ([[localException name] isEqual: NSAbortModalException] == NO) if ([[localException name] isEqual: NSAbortModalException] == NO)
[localException raise]; {
[localException raise];
}
code = NSRunAbortedResponse; code = NSRunAbortedResponse;
} }
NS_ENDHANDLER NS_ENDHANDLER
return code; return code;
} }
@ -985,8 +984,10 @@ static NSCell* tileCell = nil;
NSDate *limit; NSDate *limit;
if (theSession != session) if (theSession != session)
[NSException raise: NSInvalidArgumentException {
format: @"runModalSession: with wrong session"]; [NSException raise: NSInvalidArgumentException
format: @"runModalSession: with wrong session"];
}
pool = [NSAutoreleasePool new]; pool = [NSAutoreleasePool new];
@ -1058,18 +1059,16 @@ static NSCell* tileCell = nil;
/* /*
* Check to see if the window has gone away - if so, end session. * Check to see if the window has gone away - if so, end session.
*/ */
#if 0
if ([[self windows] indexOfObjectIdenticalTo: session->window] ==
NSNotFound || [session->window isVisible] == NO)
#else
if ([[self windows] indexOfObjectIdenticalTo: session->window] == if ([[self windows] indexOfObjectIdenticalTo: session->window] ==
NSNotFound) NSNotFound)
#endif {
[self stopModal]; [self stopModal];
}
if (windows_need_update) if (windows_need_update)
[self updateWindows]; {
[self updateWindows];
}
} }
RELEASE(pool); RELEASE(pool);
} }
@ -1080,7 +1079,7 @@ static NSCell* tileCell = nil;
- (NSWindow *) modalWindow - (NSWindow *) modalWindow
{ {
if (session) if (session != 0)
return (session->window); return (session->window);
else else
return nil; return nil;
@ -1088,7 +1087,7 @@ static NSCell* tileCell = nil;
- (void) stop: (id)sender - (void) stop: (id)sender
{ {
if (session) if (session != 0)
[self stopModal]; [self stopModal];
else else
app_is_running = NO; app_is_running = NO;
@ -1102,13 +1101,15 @@ static NSCell* tileCell = nil;
- (void) stopModalWithCode: (int)returnCode - (void) stopModalWithCode: (int)returnCode
{ {
if (session == 0) if (session == 0)
[NSException raise: NSInvalidArgumentException {
format: @"stopModalWithCode: when not in a modal session"]; [NSException raise: NSInvalidArgumentException
else format: @"stopModalWithCode: when not in a modal session"];
if (returnCode == NSRunContinuesResponse) }
else if (returnCode == NSRunContinuesResponse)
{
[NSException raise: NSInvalidArgumentException [NSException raise: NSInvalidArgumentException
format: @"stopModalWithCode: with NSRunContinuesResponse"]; format: @"stopModalWithCode: with NSRunContinuesResponse"];
}
session->runState = returnCode; session->runState = returnCode;
} }