From 5bf74fb2e5905d5d4783ce31c6eaf7d92973456f Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Tue, 16 Sep 2014 16:04:20 +0000 Subject: [PATCH] fixing #16564, partly reverting r76426 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77715 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/osx/menu_osx.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/osx/menu_osx.cpp b/src/osx/menu_osx.cpp index 5a15d80071..88676f78a2 100644 --- a/src/osx/menu_osx.cpp +++ b/src/osx/menu_osx.cpp @@ -46,6 +46,8 @@ wxMenuImpl::~wxMenuImpl() // the (popup) menu title has this special menuid static const int idMenuTitle = -3; +wxScopedPtr gs_emptyMenuBar; + // ============================================================================ // implementation // ============================================================================ @@ -73,7 +75,18 @@ void wxMenu::Init() wxMenu::~wxMenu() { - delete m_peer; +#if wxOSX_USE_CARBON + // when destroying the empty menu bar from the static scoped ptr + // the peer destructor removes an association from an already deleted + // hashmap leading to crashes. The guard avoids this, accepting some leaks... + static bool finalmenubar = false; + + if ( this == gs_emptyMenuBar.get() ) + finalmenubar = true; + + if ( !finalmenubar ) +#endif + delete m_peer; } WXHMENU wxMenu::GetHMenu() const @@ -585,8 +598,6 @@ bool wxMenuBar::s_macAutoWindowMenu = true ; WXHMENU wxMenuBar::s_macWindowMenuHandle = NULL ; -wxScopedPtr gs_emptyMenuBar; - const int firstMenuPos = 1; // to account for the 0th application menu on mac static wxMenu *CreateAppleMenu()