X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/be136f073819d425818049008ca286ff39c4cb10..713129f9d34e3027d2be46b134d2f4c490ad145f:/src/osx/cocoa/menu.mm diff --git a/src/osx/cocoa/menu.mm b/src/osx/cocoa/menu.mm index 628f38ecfb..34ea162c4d 100644 --- a/src/osx/cocoa/menu.mm +++ b/src/osx/cocoa/menu.mm @@ -55,7 +55,10 @@ @end -@interface wxNSMenuController : NSObject +@interface wxNSMenuController : NSObject +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 + +#endif { } @@ -117,11 +120,11 @@ @end -@interface NSApplication(MissingAppleMenuCall) -- (void)setAppleMenu:(NSMenu *)menu; -@end +@interface NSApplication(MissingAppleMenuCall) +- (void)setAppleMenu:(NSMenu *)menu; +@end -class wxMenuCocoaImpl : public wxMenuImpl +class wxMenuCocoaImpl : public wxMenuImpl { public : wxMenuCocoaImpl( wxMenu* peer , wxNSMenu* menu) : wxMenuImpl(peer), m_osxMenu(menu) @@ -133,33 +136,37 @@ public : } [menu setDelegate:controller]; [m_osxMenu setImplementation:this]; + // gc aware + if ( m_osxMenu ) + CFRetain(m_osxMenu); + [m_osxMenu release]; } - + virtual ~wxMenuCocoaImpl(); - - virtual void InsertOrAppend(wxMenuItem *pItem, size_t pos) + + virtual void InsertOrAppend(wxMenuItem *pItem, size_t pos) { if ( pos == (size_t) -1 ) [m_osxMenu addItem:(NSMenuItem*) pItem->GetPeer()->GetHMenuItem() ]; else [m_osxMenu insertItem:(NSMenuItem*) pItem->GetPeer()->GetHMenuItem() atIndex:pos]; } - - virtual void Remove( wxMenuItem *pItem ) + + virtual void Remove( wxMenuItem *pItem ) { [m_osxMenu removeItem:(NSMenuItem*) pItem->GetPeer()->GetHMenuItem()]; } - + virtual void MakeRoot() { [NSApp setMainMenu:m_osxMenu]; [NSApp setAppleMenu:[[m_osxMenu itemAtIndex:0] submenu]]; } - virtual void Enable( bool enable ) + virtual void Enable( bool WXUNUSED(enable) ) { } - + virtual void SetTitle( const wxString& text ) { wxCFStringRef cfText(text); @@ -196,7 +203,9 @@ wxMenuCocoaImpl::~wxMenuCocoaImpl() { [m_osxMenu setDelegate:nil]; [m_osxMenu setImplementation:nil]; - [m_osxMenu release]; + // gc aware + if ( m_osxMenu ) + CFRelease(m_osxMenu); } wxMenuImpl* wxMenuImpl::Create( wxMenu* peer, const wxString& title )