Fix crashes when window closed with key-combination (alters previous fix to work on both Tiger and Leopard). b=396860 r=joshmoz sr=roc a=dsicore

This commit is contained in:
smichaud@pobox.com 2007-10-23 11:34:29 -07:00
parent 32728903ff
commit c89edd66b8
2 changed files with 25 additions and 9 deletions

View File

@ -4025,16 +4025,8 @@ static BOOL keyUpAlreadySentKeyDown = NO;
if (!mGeckoChild || nsTSMManager::IsComposing())
return NO;
// Retain and release our native window to avoid crashes when it's closed
// as a result of processing a key equivalent (e.g. Command+w or Command+q).
NSWindow *ourNativeWindow = [self nativeWindow];
if (ourNativeWindow)
ourNativeWindow = [ourNativeWindow retain];
// see if the menu system will handle the event
BOOL menuRetval = [[NSApp mainMenu] performKeyEquivalent:theEvent];
if (ourNativeWindow)
[ourNativeWindow release];
if (menuRetval)
if ([[NSApp mainMenu] performKeyEquivalent:theEvent])
return YES;
// don't handle this if certain modifiers are down - those should

View File

@ -1315,6 +1315,18 @@ NS_IMETHODIMP nsCocoaWindow::EndSecureKeyboardInput()
geckoWindow->DispatchEvent(&guiEvent, status);
}
// Retain and release "self" to avoid crashes when our widget (and its native
// window) is closed as a result of processing a key equivalent (e.g.
// Command+w or Command+q). This workaround is only needed for a window
// that can become key.
- (BOOL)performKeyEquivalent:(NSEvent*)theEvent
{
NSWindow *nativeWindow = [self retain];
BOOL retval = [super performKeyEquivalent:theEvent];
[nativeWindow release];
return retval;
}
@end
@implementation PopupWindow
@ -1494,4 +1506,16 @@ NS_IMETHODIMP nsCocoaWindow::EndSecureKeyboardInput()
return YES;
}
// Retain and release "self" to avoid crashes when our widget (and its native
// window) is closed as a result of processing a key equivalent (e.g.
// Command+w or Command+q). This workaround is only needed for a window
// that can become key.
- (BOOL)performKeyEquivalent:(NSEvent*)theEvent
{
NSWindow *nativeWindow = [self retain];
BOOL retval = [super performKeyEquivalent:theEvent];
[nativeWindow release];
return retval;
}
@end