Fix crash in wxUniv when destroying MDI child frame

Disassociate child frame menu bar from its parent before destroying it
to avoid using a dangling pointer later, when destroying the parent.

See https://github.com/wxWidgets/wxWidgets/pull/2505

Closes #19253.
This commit is contained in:
Kvaz1r
2021-08-29 17:26:55 +03:00
committed by Vadim Zeitlin
parent 44a5cf78d1
commit bfd2d02b3e

View File

@@ -407,7 +407,15 @@ wxGenericMDIChildFrame::~wxGenericMDIChildFrame()
parent->WXRemoveChild(this);
#if wxUSE_MENUS
delete m_pMenuBar;
if ( m_pMenuBar )
{
// calling WXRemoveChild() above broke the link between the menu bar
// and the parent, so we need to also remove it explicitly
if ( parent )
parent->RemoveChild(m_pMenuBar);
delete m_pMenuBar;
}
#endif // wxUSE_MENUS
}