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
This commit is contained in:
Robert Roebling
2005-01-01 13:36:29 +00:00
parent f4430b1889
commit 62ade18051

View File

@@ -505,9 +505,10 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev
} // if ( windowPart == inMenuBar ) } // if ( windowPart == inMenuBar )
else if ( currentMouseWindow ) else if ( currentMouseWindow )
{ {
currentMouseWindow->ScreenToClient( &wxevent.m_x , &wxevent.m_y ) ;
wxWindow *currentMouseWindowParent = currentMouseWindow->GetParent(); wxWindow *currentMouseWindowParent = currentMouseWindow->GetParent();
currentMouseWindow->ScreenToClient( &wxevent.m_x , &wxevent.m_y ) ;
wxevent.SetEventObject( currentMouseWindow ) ; wxevent.SetEventObject( currentMouseWindow ) ;
// make tooltips current // make tooltips current
@@ -519,7 +520,13 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev
wxToolTip::RelayEvent( currentMouseWindow , wxevent); wxToolTip::RelayEvent( currentMouseWindow , wxevent);
#endif // wxUSE_TOOLTIPS #endif // wxUSE_TOOLTIPS
if ( currentMouseWindow->GetEventHandler()->ProcessEvent(wxevent) ) if ( currentMouseWindow->GetEventHandler()->ProcessEvent(wxevent) )
{
if ((currentMouseWindowParent != NULL) &&
(currentMouseWindowParent->GetChildren().Find(currentMouseWindow) == NULL))
currentMouseWindow = NULL;
result = noErr; result = noErr;
}
else else
{ {
// if the user code did _not_ handle the event, then perform the // 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 , HandleControlClick( (ControlRef) currentMouseWindow->GetHandle() , clickLocation ,
modifiers , (ControlActionUPP ) -1 ) ; modifiers , (ControlActionUPP ) -1 ) ;
// We need to handle the rare case that the control to if ((currentMouseWindowParent != NULL) &&
// which the currentMouseWindow points gets deleted as (currentMouseWindowParent->GetChildren().Find(currentMouseWindow) == NULL))
// a reaction to HandleControlClick. This would lead to
// a crash in the update cursor code below.
if (!currentMouseWindowParent->GetChildren().Find( currentMouseWindow ))
currentMouseWindow = NULL; currentMouseWindow = NULL;
} }
result = noErr ; result = noErr ;