X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f7f50f493baa177e8ae07d12641095baee55d4f8..5e3841bf8069fbcc2b1da3ef36af4f569c604265:/src/msw/menu.cpp diff --git a/src/msw/menu.cpp b/src/msw/menu.cpp index eb78604c7d..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; + } } // --------------------------------------------------------------------------- @@ -838,8 +845,6 @@ void wxMenuBar::Attach(wxFrame *frame) void wxMenuBar::Detach() { - m_hMenu = (WXHMENU)NULL; - wxMenuBarBase::Detach(); }