X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/542875a8c4f12b16fef8c1c25ee7e8166902f9bb..21e5527b592198bf3433969313e1c376d12c1305:/src/os2/frame.cpp?ds=sidebyside diff --git a/src/os2/frame.cpp b/src/os2/frame.cpp index 4c15e005b4..d697f9ca5d 100644 --- a/src/os2/frame.cpp +++ b/src/os2/frame.cpp @@ -527,23 +527,25 @@ void wxFrame::SetMenuBar( return; } - wxCHECK_RET(!pMenuBar->GetFrame(), wxT("this menubar is already attached")); + m_frameMenuBar = NULL; - if (m_frameMenuBar) - delete m_frameMenuBar; - - m_hMenu = pMenuBar->Create(); - m_ulMenubarId = pMenuBar->GetMenubarId(); - if (m_ulMenubarId != FID_MENU) + // Can set a menubar several times. + // TODO: how to prevent a memory leak if you have a currently-unattached + // menubar? wxWindows assumes that the frame will delete the menu (otherwise + // there are problems for MDI). + if (pMenuBar->GetHMenu()) { - ::WinSetWindowUShort( m_hMenu - ,QWS_ID - ,(unsigned short)m_ulMenubarId - ); + m_hMenu = pMenuBar->GetHMenu(); } + else + { + pMenuBar->Detach(); - if (!m_hMenu) - return; + m_hMenu = pMenuBar->Create(); + + if (!m_hMenu) + return; + } InternalSetMenuBar();