Avoid crashes when deleting owned top level windows.

Don't delay the TLW destruction if it has a parent and its parent is already
being deleted: we can't delay the inevitable in this case and only succeed in
making the program crash if we try.

Closes #15743.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_3_0_BRANCH@75833 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2014-02-07 14:35:48 +00:00
parent 7e1a702bc7
commit 0dd099f3c5

View File

@@ -101,6 +101,16 @@ wxTopLevelWindowBase::~wxTopLevelWindowBase()
bool wxTopLevelWindowBase::Destroy() bool wxTopLevelWindowBase::Destroy()
{ {
// We can't delay the destruction if our parent is being already destroyed
// as we will be deleted anyhow during its destruction and the pointer
// stored in wxPendingDelete would become invalid, so just delete ourselves
// immediately in this case.
if ( wxWindow* parent = GetParent() )
{
if ( parent->IsBeingDeleted() )
return wxNonOwnedWindow::Destroy();
}
// delayed destruction: the frame will be deleted during the next idle // delayed destruction: the frame will be deleted during the next idle
// loop iteration // loop iteration
if ( !wxPendingDelete.Member(this) ) if ( !wxPendingDelete.Member(this) )