guarding against events sent to semi-destroyed instances, fixes #10418
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@58509 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -344,42 +344,48 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
|
|||||||
ControlPartCode currentControlPart = cEvent.GetParameter<ControlPartCode>(kEventParamControlCurrentPart , typeControlPartCode );
|
ControlPartCode currentControlPart = cEvent.GetParameter<ControlPartCode>(kEventParamControlCurrentPart , typeControlPartCode );
|
||||||
if ( currentControlPart == 0 )
|
if ( currentControlPart == 0 )
|
||||||
{
|
{
|
||||||
// kill focus
|
if ( thisWindow->IsBeingDeleted() == false )
|
||||||
|
{
|
||||||
|
// kill focus
|
||||||
#if wxUSE_CARET
|
#if wxUSE_CARET
|
||||||
if ( thisWindow->GetCaret() )
|
if ( thisWindow->GetCaret() )
|
||||||
thisWindow->GetCaret()->OnKillFocus();
|
thisWindow->GetCaret()->OnKillFocus();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxLogTrace(_T("Focus"), _T("focus lost(%p)"), wx_static_cast(void*, thisWindow));
|
wxLogTrace(_T("Focus"), _T("focus lost(%p)"), wx_static_cast(void*, thisWindow));
|
||||||
|
|
||||||
// remove this as soon as posting the synthesized event works properly
|
// remove this as soon as posting the synthesized event works properly
|
||||||
static bool inKillFocusEvent = false ;
|
static bool inKillFocusEvent = false ;
|
||||||
|
|
||||||
if ( !inKillFocusEvent )
|
if ( !inKillFocusEvent )
|
||||||
{
|
{
|
||||||
inKillFocusEvent = true ;
|
inKillFocusEvent = true ;
|
||||||
wxFocusEvent event( wxEVT_KILL_FOCUS, thisWindow->GetId());
|
wxFocusEvent event( wxEVT_KILL_FOCUS, thisWindow->GetId());
|
||||||
event.SetEventObject(thisWindow);
|
event.SetEventObject(thisWindow);
|
||||||
thisWindow->GetEventHandler()->ProcessEvent(event) ;
|
thisWindow->GetEventHandler()->ProcessEvent(event) ;
|
||||||
inKillFocusEvent = false ;
|
inKillFocusEvent = false ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( previousControlPart == 0 )
|
else if ( previousControlPart == 0 )
|
||||||
{
|
{
|
||||||
// set focus
|
if ( thisWindow->IsBeingDeleted() == false )
|
||||||
// panel wants to track the window which was the last to have focus in it
|
{
|
||||||
wxLogTrace(_T("Focus"), _T("focus set(%p)"), wx_static_cast(void*, thisWindow));
|
// set focus
|
||||||
wxChildFocusEvent eventFocus((wxWindow*)thisWindow);
|
// panel wants to track the window which was the last to have focus in it
|
||||||
thisWindow->GetEventHandler()->ProcessEvent(eventFocus);
|
wxLogTrace(_T("Focus"), _T("focus set(%p)"), wx_static_cast(void*, thisWindow));
|
||||||
|
wxChildFocusEvent eventFocus((wxWindow*)thisWindow);
|
||||||
|
thisWindow->GetEventHandler()->ProcessEvent(eventFocus);
|
||||||
|
|
||||||
#if wxUSE_CARET
|
#if wxUSE_CARET
|
||||||
if ( thisWindow->GetCaret() )
|
if ( thisWindow->GetCaret() )
|
||||||
thisWindow->GetCaret()->OnSetFocus();
|
thisWindow->GetCaret()->OnSetFocus();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxFocusEvent event(wxEVT_SET_FOCUS, thisWindow->GetId());
|
wxFocusEvent event(wxEVT_SET_FOCUS, thisWindow->GetId());
|
||||||
event.SetEventObject(thisWindow);
|
event.SetEventObject(thisWindow);
|
||||||
thisWindow->GetEventHandler()->ProcessEvent(event) ;
|
thisWindow->GetEventHandler()->ProcessEvent(event) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user