From 1633eb4ac36bf918132f48c160bdf24b7d71e62b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 18 Nov 2013 14:21:02 +0000 Subject: [PATCH] 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/branches/WX_3_0_BRANCH@75244 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/mdi.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/msw/mdi.cpp b/src/msw/mdi.cpp index 0645e4beb5..5a1aae5373 100644 --- a/src/msw/mdi.cpp +++ b/src/msw/mdi.cpp @@ -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