X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/be15b995df23c3ca511098676fbdc872f59add80..5e3841bf8069fbcc2b1da3ef36af4f569c604265:/src/msw/menu.cpp diff --git a/src/msw/menu.cpp b/src/msw/menu.cpp index 659634d90a..6420604cc5 100644 --- a/src/msw/menu.cpp +++ b/src/msw/menu.cpp @@ -557,6 +557,13 @@ wxMenuBar::wxMenuBar(int count, wxMenu *menus[], const wxString titles[]) wxMenuBar::~wxMenuBar() { + // we should free Windows resources only if Windows doesn't do it for us + // which happens if we're attached to a frame + if (m_hMenu && !IsAttached()) + { + ::DestroyMenu((HMENU)m_hMenu); + m_hMenu = (WXHMENU)NULL; + } } // --------------------------------------------------------------------------- @@ -673,7 +680,8 @@ wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title) { wxMenu *menuOld = wxMenuBarBase::Replace(pos, menu, title); if ( !menuOld ) - return FALSE; + return NULL; + m_titles[pos] = title; if ( IsAttached() ) @@ -837,8 +845,6 @@ void wxMenuBar::Attach(wxFrame *frame) void wxMenuBar::Detach() { - m_hMenu = (WXHMENU)NULL; - wxMenuBarBase::Detach(); }