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
This commit is contained in:
Vadim Zeitlin
2010-08-22 22:15:22 +00:00
parent 4b97af90bf
commit 45d1c40a91

View File

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