don't try to update TLW default button in WM_SET/KILLFOCUS handlers if the TLW is being deleted (bug 1660913) [backport from HEAD]
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@45958 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -357,12 +357,33 @@ void wxButton::SetDefault()
|
|||||||
SetDefaultStyle(this, true);
|
SetDefaultStyle(this, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// special version of wxGetTopLevelParent() which is safe to call when the
|
||||||
|
// parent is being destroyed: wxGetTopLevelParent() would just return NULL in
|
||||||
|
// this case because wxWindow version of IsTopLevel() is used when it's called
|
||||||
|
// during window destruction instead of wxTLW one, but we want to distinguish
|
||||||
|
// between these cases
|
||||||
|
static wxTopLevelWindow *GetTLWParentIfNotBeingDeleted(wxWindow *win)
|
||||||
|
{
|
||||||
|
for ( ; win; win = win->GetParent() )
|
||||||
|
{
|
||||||
|
if ( win->IsBeingDeleted() )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if ( win->IsTopLevel() )
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxASSERT_MSG( win, _T("button without top level parent?") );
|
||||||
|
|
||||||
|
return wxDynamicCast(win, wxTopLevelWindow);
|
||||||
|
}
|
||||||
|
|
||||||
// set this button as being currently default
|
// set this button as being currently default
|
||||||
void wxButton::SetTmpDefault()
|
void wxButton::SetTmpDefault()
|
||||||
{
|
{
|
||||||
wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
|
wxTopLevelWindow * const tlw = GetTLWParentIfNotBeingDeleted(GetParent());
|
||||||
|
if ( !tlw )
|
||||||
wxCHECK_RET( tlw, _T("button without top level window?") );
|
return;
|
||||||
|
|
||||||
wxWindow *winOldDefault = tlw->GetDefaultItem();
|
wxWindow *winOldDefault = tlw->GetDefaultItem();
|
||||||
tlw->SetTmpDefaultItem(this);
|
tlw->SetTmpDefaultItem(this);
|
||||||
@@ -374,9 +395,9 @@ void wxButton::SetTmpDefault()
|
|||||||
// unset this button as currently default, it may still stay permanent default
|
// unset this button as currently default, it may still stay permanent default
|
||||||
void wxButton::UnsetTmpDefault()
|
void wxButton::UnsetTmpDefault()
|
||||||
{
|
{
|
||||||
wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
|
wxTopLevelWindow * const tlw = GetTLWParentIfNotBeingDeleted(GetParent());
|
||||||
|
if ( !tlw )
|
||||||
wxCHECK_RET( tlw, _T("button without top level window?") );
|
return;
|
||||||
|
|
||||||
tlw->SetTmpDefaultItem(NULL);
|
tlw->SetTmpDefaultItem(NULL);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user