Don't crash on Objective-C exceptions in a hooked system call ([NSWindow sendEvent:]). b=442245 r=josh

sr=roc a=dveditz


git-svn-id: svn://10.0.0.236/trunk@254577 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
smichaud%pobox.com 2008-10-09 21:01:46 +00:00
parent c865293da3
commit 4bcef5c505
2 changed files with 10 additions and 2 deletions

View File

@ -2159,7 +2159,10 @@ already_AddRefed<nsIDOMElement> GetFocusedElement()
// NSWindow's own sendEvent: method.
- (void)nsCocoaWindow_NSWindow_sendEvent:(NSEvent *)anEvent
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
// Since we've hooked a "system call" ([NSWindow sendEvent:]), we're always
// called from system code (not browser code). So avoid crashing on any
// Objective-C exceptions that occur here.
NS_OBJC_BEGIN_TRY_LOGONLY_BLOCK;
nsCOMPtr<nsIDOMElement> oldFocusedElement;
NSResponder *oldFirstResponder;
@ -2198,7 +2201,7 @@ already_AddRefed<nsIDOMElement> GetFocusedElement()
[oldFirstResponder release];
}
NS_OBJC_END_TRY_ABORT_BLOCK;
NS_OBJC_END_TRY_LOGONLY_BLOCK;
}
@end

View File

@ -221,4 +221,9 @@ NS_OBJC_TRY(_e, )
} \
return _rv;
#define NS_OBJC_BEGIN_TRY_LOGONLY_BLOCK @try {
#define NS_OBJC_END_TRY_LOGONLY_BLOCK } @catch(NSException *_exn) { \
nsObjCExceptionLog(_exn); \
}
#endif // nsObjCExceptions_h_