X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ffad7b0dd2907634d93daacfb54d503c6f7a4ad4..c3e433b15929171af57df3c9c3c63d6ab8aa720b:/src/osx/cocoa/menu.mm diff --git a/src/osx/cocoa/menu.mm b/src/osx/cocoa/menu.mm index 3127597356..628f38ecfb 100644 --- a/src/osx/cocoa/menu.mm +++ b/src/osx/cocoa/menu.mm @@ -39,6 +39,7 @@ - (id) init { [super init]; + impl = NULL; return self; } @@ -123,8 +124,15 @@ class wxMenuCocoaImpl : public wxMenuImpl { public : - wxMenuCocoaImpl( wxMenu* peer , NSMenu* menu) : wxMenuImpl(peer), m_osxMenu(menu) + wxMenuCocoaImpl( wxMenu* peer , wxNSMenu* menu) : wxMenuImpl(peer), m_osxMenu(menu) { + static wxNSMenuController* controller = NULL; + if ( controller == NULL ) + { + controller = [[wxNSMenuController alloc] init]; + } + [menu setDelegate:controller]; + [m_osxMenu setImplementation:this]; } virtual ~wxMenuCocoaImpl(); @@ -181,25 +189,20 @@ public : static wxMenuImpl* Create( wxMenu* peer, const wxString& title ); static wxMenuImpl* CreateRootMenu( wxMenu* peer ); protected : - NSMenu* m_osxMenu; + wxNSMenu* m_osxMenu; } ; wxMenuCocoaImpl::~wxMenuCocoaImpl() { + [m_osxMenu setDelegate:nil]; + [m_osxMenu setImplementation:nil]; [m_osxMenu release]; } wxMenuImpl* wxMenuImpl::Create( wxMenu* peer, const wxString& title ) { - static wxNSMenuController* controller = NULL; - if ( controller == NULL ) - { - controller = [[wxNSMenuController alloc] init]; - } wxCFStringRef cfText( title ); wxNSMenu* menu = [[wxNSMenu alloc] initWithTitle:cfText.AsNSString()]; wxMenuImpl* c = new wxMenuCocoaImpl( peer, menu ); - [menu setDelegate:controller]; - [menu setImplementation:c]; return c; }