Fix application termination behavior by sending a message to the

document controller to let the user review any unsaved changes in its
managed documents before asking the application delegate whether its
okay to terminate the application. This matches Cocoa's documented and
implemented behavior.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@31957 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Wolfgang Lux 2011-01-27 20:32:01 +00:00
parent 18806fd515
commit 3da944c1dd
2 changed files with 30 additions and 20 deletions

View file

@ -1,3 +1,17 @@
2011-01-27 Wolfgang Lux <wolfgang.lux@gmail.com>
* Source/NSApplication.m (-terminate:): Send message to the
document controller to let the user review any unsaved changes in
its managed documents before asking the application delegate
whether its okay to terminate the application. This matches
Cocoa's documented and implemented behavior.
* Source/NSApplication.m (-terminate): Move call to GSRemoveIcon
from here ...
* Source/NSApplication.m (-replyToApplicationShouldTerminate:):
... to here to ensure that the app icon is removed from the icon
manager even when the delegate delays application termination.
2011-01-26 Wolfgang Lux <wolfgang.lux@gmail.com>
* Headers/AppKit/NSWindow.h: Add missing declaration of the

View file

@ -3432,8 +3432,22 @@ struct _DelegateWrapper
*/
- (void) terminate: (id)sender
{
NSApplicationTerminateReply termination = NSTerminateNow;
NSDocumentController *sdc;
NSApplicationTerminateReply termination;
/* First ask the shared document controller to save any unsaved changes */
sdc = [NSDocumentController sharedDocumentController];
if ([[sdc documentClassNames] count] > 0)
{
if ([sdc reviewUnsavedDocumentsWithAlertTitle: _(@"Quit")
cancellable: YES] == NO)
{
return;
}
}
/* Now ask the application delegate whether its okay to terminate */
termination = NSTerminateNow;
if ([_delegate respondsToSelector: @selector(applicationShouldTerminate:)])
{
/* The old API has applicationShouldTerminate: return a BOOL,
@ -3447,28 +3461,9 @@ struct _DelegateWrapper
*/
termination = ([_delegate applicationShouldTerminate: self] & 0xff);
}
else
{
NSDocumentController *sdc;
sdc = [NSDocumentController sharedDocumentController];
if ([[sdc documentClassNames] count] > 0)
{
if ([sdc reviewUnsavedDocumentsWithAlertTitle: _(@"Quit")
cancellable: YES] == YES)
{
termination = NSTerminateNow;
}
else
{
termination = NSTerminateCancel;
}
}
}
if (termination == NSTerminateNow)
{
GSRemoveIcon(_app_icon_window);
[self replyToApplicationShouldTerminate: YES];
}
/*
@ -3492,6 +3487,7 @@ struct _DelegateWrapper
_app_is_running = NO;
GSRemoveIcon(_app_icon_window);
[[self windows] makeObjectsPerformSelector: @selector(close)];
[NSCursor setHiddenUntilMouseMoves: NO];