From: Robert Roebling Date: Fri, 31 Dec 2004 10:22:32 +0000 (+0000) Subject: Fixes a rare crash. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/e10e94693f6c763025455c996db542cce86b1e2f Fixes a rare crash. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31195 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/mac/carbon/toplevel.cpp b/src/mac/carbon/toplevel.cpp index ee145443cc..89ef280b1a 100644 --- a/src/mac/carbon/toplevel.cpp +++ b/src/mac/carbon/toplevel.cpp @@ -506,6 +506,7 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev else if ( currentMouseWindow ) { currentMouseWindow->ScreenToClient( &wxevent.m_x , &wxevent.m_y ) ; + wxWindow *currentMouseWindowParent = currentMouseWindow->GetParent(); wxevent.SetEventObject( currentMouseWindow ) ; @@ -547,6 +548,13 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev #endif HandleControlClick( (ControlRef) currentMouseWindow->GetHandle() , clickLocation , modifiers , (ControlActionUPP ) -1 ) ; + + // We need to handle the rare case that the control to + // which the currentMouseWindow points gets deleted as + // a reaction to HandleControlClick. This would lead to + // a crash in the update cursor code below. + if (!currentMouseWindowParent->GetChildren().Find( currentMouseWindow )) + currentMouseWindow = NULL; } result = noErr ; } @@ -566,7 +574,7 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev { cursorTarget = cursorTarget->GetParent() ; if ( cursorTarget ) - cursorPoint += cursorTarget->GetPosition() ; + cursorPoint += cursorTarget->GetPosition(); } } // else if ( currentMouseWindow )