mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 03:21:04 +00:00
Hopefully clear up some confusion about NSApplicationTerminateReply
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@26375 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
b416d00ef8
commit
1007fd1273
2 changed files with 32 additions and 8 deletions
|
@ -1,3 +1,8 @@
|
|||
2008-03-26 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSApplication.m: fixed termination type code and added
|
||||
comments to avoid confusion.
|
||||
|
||||
2008-03-20 Nicola Pero <nicola.pero@meta-innovation.com>
|
||||
|
||||
* Source/NSTextFieldCell.m ([-drawInteriorWithFrame:inView:]): If
|
||||
|
|
|
@ -3198,28 +3198,47 @@ struct _DelegateWrapper
|
|||
/**
|
||||
* Requests the application terminates the application. First an
|
||||
* -applicationShouldTerminate: message is sent to the delegate, and only if
|
||||
* it returns YES (or <code>NSTerminateNow</code>) will termination be
|
||||
* carried out.
|
||||
* it returns <code>NSTerminateNow</code> will termination be
|
||||
* carried out.<br />
|
||||
* The old version of -applicationShouldTerminate: returned a BOOL, and this
|
||||
* behavior is handled for backward compatibility with YES being
|
||||
* equivalent to <code>NSTerminateNow</code> and NO being
|
||||
* equivalent to <code>NSTerminateCancel</code>.
|
||||
*/
|
||||
- (void) terminate: (id)sender
|
||||
{
|
||||
BOOL shouldTerminate = YES;
|
||||
NSApplicationTerminateReply termination;
|
||||
|
||||
if ([_delegate respondsToSelector: @selector(applicationShouldTerminate:)])
|
||||
{
|
||||
shouldTerminate = [_delegate applicationShouldTerminate: self];
|
||||
/* The old API has applicationShouldTerminate: return a BOOL,
|
||||
* so if we are linked in to an application which used that
|
||||
* API, the delegate might return a BOOL rather than an
|
||||
* NSTerminateNow. That's fine as both NSTerminateNow
|
||||
* and BOOL are integers, and NSTerminateNow is defined as YES
|
||||
* and NSTerminateCancel as NO.
|
||||
*/
|
||||
termination = (NSApplicationTerminateReply)
|
||||
[_delegate applicationShouldTerminate: self];
|
||||
}
|
||||
else
|
||||
{
|
||||
if ([NSDocumentController isDocumentBasedApplication])
|
||||
{
|
||||
shouldTerminate = [[NSDocumentController sharedDocumentController]
|
||||
reviewUnsavedDocumentsWithAlertTitle: _(@"Quit")
|
||||
cancellable:YES];
|
||||
if ([[NSDocumentController sharedDocumentController]
|
||||
reviewUnsavedDocumentsWithAlertTitle: _(@"Quit")
|
||||
cancellable: YES] == YES)
|
||||
{
|
||||
termination = NSTerminateNow;
|
||||
}
|
||||
else
|
||||
{
|
||||
termination = NSTerminateCancel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldTerminate == NSTerminateNow)
|
||||
if (termination == NSTerminateNow)
|
||||
{
|
||||
[self replyToApplicationShouldTerminate: YES];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue