From: Vadim Zeitlin Date: Sun, 22 Aug 2010 22:15:22 +0000 (+0000) Subject: Work around a crash on starting editing in wxGrid under wxOSX/Cocoa. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/45d1c40a918c3e7324a7c86cac608185cac58b79?ds=sidebyside Work around a crash on starting editing in wxGrid under wxOSX/Cocoa. wxOSX/Cocoa currently generates unexpected focus loss events with the window gaining focus being the same one as losing it. This is wrong and shouldn't happen but as long as it does, filter these events out to at least allow editing the grid to work. See #12267. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65382 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm index a297d9c1fb..9e27c22e6e 100644 --- a/src/osx/cocoa/window.mm +++ b/src/osx/cocoa/window.mm @@ -1039,6 +1039,15 @@ bool wxWidgetCocoaImpl::resignFirstResponder(WXWidget slf, void *_cmd) // is resigning NSView* otherView = FindFocus(); wxWidgetImpl* otherWindow = FindFromWXWidget(otherView); + + // It doesn't make sense to notify about the loss of focus if we're not + // really losing it and the window which has just gained focus is the same + // one as this window itself. Of course, this should never happen in the + // first place but somehow it does in wxGrid code and without this check we + // enter into an infinite recursion, see #12267. + if ( otherWindow == this ) + return r; + // NSTextViews have an editor as true responder, therefore the might get the // resign notification if their editor takes over, don't trigger any event then if ( r && !m_hasEditor)