backport, fixes #16564

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_3_0_BRANCH@77716 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2014-09-16 16:05:46 +00:00
parent 721743ae37
commit 228ecaad8b

View File

@@ -46,6 +46,8 @@ wxMenuImpl::~wxMenuImpl()
// the (popup) menu title has this special menuid // the (popup) menu title has this special menuid
static const int idMenuTitle = -3; static const int idMenuTitle = -3;
wxScopedPtr<wxMenu> gs_emptyMenuBar;
// ============================================================================ // ============================================================================
// implementation // implementation
// ============================================================================ // ============================================================================
@@ -73,6 +75,17 @@ void wxMenu::Init()
wxMenu::~wxMenu() wxMenu::~wxMenu()
{ {
#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; delete m_peer;
} }
@@ -585,8 +598,6 @@ bool wxMenuBar::s_macAutoWindowMenu = true ;
WXHMENU wxMenuBar::s_macWindowMenuHandle = NULL ; WXHMENU wxMenuBar::s_macWindowMenuHandle = NULL ;
wxScopedPtr<wxMenu> gs_emptyMenuBar;
const int firstMenuPos = 1; // to account for the 0th application menu on mac const int firstMenuPos = 1; // to account for the 0th application menu on mac
static wxMenu *CreateAppleMenu() static wxMenu *CreateAppleMenu()