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
Родитель ccb50b04c5
Коммит c3c1989ae5
2 изменённых файлов: 25 добавлений и 9 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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