From ce1514ce6c0c3825b611eb782a10b90c873d69bf Mon Sep 17 00:00:00 2001 From: Stephen A Pohl Date: Thu, 18 May 2017 15:37:01 -0400 Subject: [PATCH] Bug 1365825: Fix occasional crashes on OSX when handling custom shortcuts. r=mstange --- widget/cocoa/nsChildView.mm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index a78aa1ebc7ca..912728702be1 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -1284,9 +1284,7 @@ nsChildView::PostHandleKeyEvent(mozilla::WidgetKeyboardEvent* aEvent) // not handled we give menu items a chance to act. This allows for handling of // custom shortcuts. Note that existing shortcuts cannot be reassigned yet and // will have been handled by keyDown: before we get here. - NSEvent* cocoaEvent = - [sNativeKeyEventsMap objectForKey:@(aEvent->mUniqueId)]; - [sNativeKeyEventsMap removeObjectForKey:@(aEvent->mUniqueId)]; + NSEvent* cocoaEvent = [sNativeKeyEventsMap objectForKey:@(aEvent->mUniqueId)]; if (!cocoaEvent) { return; } @@ -1294,6 +1292,7 @@ nsChildView::PostHandleKeyEvent(mozilla::WidgetKeyboardEvent* aEvent) if (SendEventToNativeMenuSystem(cocoaEvent)) { aEvent->PreventDefault(); } + [sNativeKeyEventsMap removeObjectForKey:@(aEvent->mUniqueId)]; NS_OBJC_END_TRY_ABORT_BLOCK; }