fix memory leak for initial empty menubar, see #15666
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76426 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -31,6 +31,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/osx/private.h"
|
#include "wx/osx/private.h"
|
||||||
|
#include "wx/scopedptr.h"
|
||||||
|
|
||||||
// other standard headers
|
// other standard headers
|
||||||
// ----------------------
|
// ----------------------
|
||||||
@@ -584,7 +585,7 @@ bool wxMenuBar::s_macAutoWindowMenu = true ;
|
|||||||
WXHMENU wxMenuBar::s_macWindowMenuHandle = NULL ;
|
WXHMENU wxMenuBar::s_macWindowMenuHandle = NULL ;
|
||||||
|
|
||||||
|
|
||||||
wxMenu* emptyMenuBar = 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
|
||||||
|
|
||||||
@@ -637,10 +638,10 @@ static wxMenu *CreateAppleMenu()
|
|||||||
|
|
||||||
void wxMenuBar::Init()
|
void wxMenuBar::Init()
|
||||||
{
|
{
|
||||||
if ( emptyMenuBar == NULL )
|
if ( !gs_emptyMenuBar )
|
||||||
{
|
{
|
||||||
emptyMenuBar = new wxMenu();
|
gs_emptyMenuBar.reset( new wxMenu() );
|
||||||
emptyMenuBar->AppendSubMenu(CreateAppleMenu(), "\x14") ;
|
gs_emptyMenuBar->AppendSubMenu(CreateAppleMenu(), "\x14") ;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_eventHandler = this;
|
m_eventHandler = this;
|
||||||
@@ -682,7 +683,7 @@ wxMenuBar::~wxMenuBar()
|
|||||||
|
|
||||||
if (s_macInstalledMenuBar == this)
|
if (s_macInstalledMenuBar == this)
|
||||||
{
|
{
|
||||||
emptyMenuBar->GetPeer()->MakeRoot();
|
gs_emptyMenuBar->GetPeer()->MakeRoot();
|
||||||
s_macInstalledMenuBar = NULL;
|
s_macInstalledMenuBar = NULL;
|
||||||
}
|
}
|
||||||
wxDELETE( m_rootMenu );
|
wxDELETE( m_rootMenu );
|
||||||
|
Reference in New Issue
Block a user