X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/829a2e9521175cd943d671f16535242a467c4f91..6540d8d2bae4652270096b439991dd9ccb417cc1:/src/cocoa/NSMenu.mm diff --git a/src/cocoa/NSMenu.mm b/src/cocoa/NSMenu.mm index 18451658af..c59ee77a0a 100644 --- a/src/cocoa/NSMenu.mm +++ b/src/cocoa/NSMenu.mm @@ -15,8 +15,8 @@ #include "wx/log.h" #endif // WX_PRECOMP +#include "wx/cocoa/ObjcRef.h" #include "wx/cocoa/NSMenu.h" -#include "wx/cocoa/ObjcPose.h" #import #include "wx/cocoa/objc/NSMenu.h" @@ -36,6 +36,7 @@ } @end // WXNSMenu +WX_IMPLEMENT_GET_OBJC_CLASS(WXNSMenu,NSMenu) // ============================================================================ // @class wxNSMenuNotificationObserver @@ -44,14 +45,13 @@ { } -struct objc_object *wxCocoaNSMenu::sm_cocoaObserver = [[wxNSMenuNotificationObserver alloc] init]; - - (void)menuDidAddItem: (NSNotification *)notification; - (void)menuDidChangeItem: (NSNotification *)notification; - (void)menuDidRemoveItem: (NSNotification *)notification; - (void)menuDidSendAction: (NSNotification *)notification; - (void)menuWillSendAction: (NSNotification *)notification; @end // interface wxNSMenuNotificationObserver +WX_DECLARE_GET_OBJC_CLASS(wxNSMenuNotificationObserver,NSObject) @implementation wxNSMenuNotificationObserver : NSObject @@ -91,12 +91,18 @@ struct objc_object *wxCocoaNSMenu::sm_cocoaObserver = [[wxNSMenuNotificationObse } @end // implementation wxNSMenuNotificationObserver +WX_IMPLEMENT_GET_OBJC_CLASS(wxNSMenuNotificationObserver,NSObject) // ======================================================================== // wxCocoaNSMenu // ======================================================================== WX_IMPLEMENT_OBJC_INTERFACE_HASHMAP(NSMenu) +// New CF-retained observer (this should have been using wxObjcAutoRefFromAlloc to begin with) +static wxObjcAutoRefFromAlloc s_cocoaNSMenuObserver([[WX_GET_OBJC_CLASS(wxNSMenuNotificationObserver) alloc] init]); +// For compatibility with old code +struct objc_object *wxCocoaNSMenu::sm_cocoaObserver = s_cocoaNSMenuObserver; + void wxCocoaNSMenu::AssociateNSMenu(WX_NSMenu cocoaNSMenu, unsigned int flags) { if(cocoaNSMenu)