Fix replacing "Window" menu in wxMDIParentFrame in wxMSW.

When setting a new "Window" menu (as opposed to just modifying the existing
one which did work correctly), we shouldn't show it immediately in the menu
bar if there are no MDI children, this results in wrong UI and assert
failures.

Closes #15663.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75242 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2013-11-18 14:19:49 +00:00
parent fec6f3bea1
commit 7a71061eb7

View File

@ -374,15 +374,19 @@ void wxMDIParentFrame::SetWindowMenu(wxMenu* menu)
{
if ( menu != m_windowMenu )
{
// notice that Remove/AddWindowMenu() are safe to call even when
// m_windowMenu is NULL
RemoveWindowMenu();
// We may not be showing the window menu currently if we don't have any
// children, and in this case we shouldn't remove/add it back right now.
const bool hasWindowMenu = GetActiveChild() != NULL;
if ( hasWindowMenu )
RemoveWindowMenu();
delete m_windowMenu;
m_windowMenu = menu;
AddWindowMenu();
if ( hasWindowMenu )
AddWindowMenu();
}
#if wxUSE_ACCEL