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/trunk@75447 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -101,6 +101,16 @@ wxTopLevelWindowBase::~wxTopLevelWindowBase()
|
||||
|
||||
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
|
||||
// loop iteration
|
||||
if ( !wxPendingDelete.Member(this) )
|
||||
|
Reference in New Issue
Block a user