From 62ade1805148edf0d228b92bbdade5323a8921b9 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sat, 1 Jan 2005 13:36:29 +0000 Subject: [PATCH] Second attempt to fix a rare crash (bad mem access after deletion of a control) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31210 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/toplevel.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/mac/carbon/toplevel.cpp b/src/mac/carbon/toplevel.cpp index 89ef280b1a..1ce8d60fde 100644 --- a/src/mac/carbon/toplevel.cpp +++ b/src/mac/carbon/toplevel.cpp @@ -505,8 +505,9 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev } // if ( windowPart == inMenuBar ) else if ( currentMouseWindow ) { - currentMouseWindow->ScreenToClient( &wxevent.m_x , &wxevent.m_y ) ; wxWindow *currentMouseWindowParent = currentMouseWindow->GetParent(); + + currentMouseWindow->ScreenToClient( &wxevent.m_x , &wxevent.m_y ) ; wxevent.SetEventObject( currentMouseWindow ) ; @@ -519,7 +520,13 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev wxToolTip::RelayEvent( currentMouseWindow , wxevent); #endif // wxUSE_TOOLTIPS if ( currentMouseWindow->GetEventHandler()->ProcessEvent(wxevent) ) + { + if ((currentMouseWindowParent != NULL) && + (currentMouseWindowParent->GetChildren().Find(currentMouseWindow) == NULL)) + currentMouseWindow = NULL; + result = noErr; + } else { // if the user code did _not_ handle the event, then perform the @@ -549,11 +556,8 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev 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 )) + if ((currentMouseWindowParent != NULL) && + (currentMouseWindowParent->GetChildren().Find(currentMouseWindow) == NULL)) currentMouseWindow = NULL; } result = noErr ; -- 2.45.2