diff --git a/docs/changes.txt b/docs/changes.txt index 2487ba62c9..09b0140a6b 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -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 diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index 41c8a455bd..65c33625ae 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -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