fix crash after destroying a default button in a backwards compatible way (patch 1727956)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@46272 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-06-02 13:25:43 +00:00
parent 4be667976c
commit 79ac0cd199
2 changed files with 23 additions and 13 deletions

View File

@@ -91,16 +91,9 @@ Major new features in 2.8 release
2.8.5
-----
All:
All (Unix):
All (GUI):
wxMSW:
- Fix crash when destroying a default button (Tim Kosse)
- Correct problem with page setup dialog when using landscape mode
- Added msw.font.no-proof-quality system option, see manual for description
- Fix appearance of notebook with non-top tabs under Windows Vista

View File

@@ -324,10 +324,27 @@ wxWindowBase::~wxWindowBase()
wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent((wxWindow*)this),
wxTopLevelWindow);
if ( tlw && tlw->GetDefaultItem() == this )
tlw->SetDefaultItem(NULL);
if ( tlw && tlw->GetTmpDefaultItem() == this )
tlw->SetTmpDefaultItem(NULL);
if ( tlw )
{
wxWindow* tmpDefaultItem = tlw->GetTmpDefaultItem();
if ( tmpDefaultItem == this )
tlw->SetTmpDefaultItem(NULL);
else if ( tmpDefaultItem )
{
// A temporary default item masks the real default item, so
// temporarily unset the temporary default item so we can access the
// real default item.
tlw->SetTmpDefaultItem(NULL);
if ( tlw->GetDefaultItem() == this )
tlw->SetDefaultItem(NULL);
// Set the temporary default item back.
tlw->SetTmpDefaultItem(tmpDefaultItem);
}
else if ( tlw->GetDefaultItem() == this )
tlw->SetDefaultItem(NULL);
}
}
// reset the dangling pointer our parent window may keep to us