Put wxAutoNSAutoreleasePool in methods that may be used outside the run loop.
[wxWidgets.git] / src / cocoa / NSMenu.mm
1 /////////////////////////////////////////////////////////////////////////////
2 // Name:        cocoa/NSMenu.mm
3 // Purpose:     wxCocoaNSMenu implementation
4 // Author:      David Elliott
5 // Modified by:
6 // Created:     2002/12/09
7 // RCS-ID:      $Id: 
8 // Copyright:   (c) 2002 David Elliott
9 // Licence:     wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #include "wx/wxprec.h"
21 #ifndef WX_PRECOMP
22     #include "wx/log.h"
23 #endif // WX_PRECOMP
24
25 #include "wx/cocoa/NSMenu.h"
26 #include "wx/cocoa/ObjcPose.h"
27 #include "wx/cocoa/autorelease.h"
28
29 #import <Foundation/NSString.h>
30 #import <AppKit/NSMenu.h>
31
32 #if wxUSE_MENUS
33
34 // ----------------------------------------------------------------------------
35 // globals
36 // ----------------------------------------------------------------------------
37
38 // ============================================================================
39 // @class wxPoserNSMenu
40 // ============================================================================
41 @interface wxPoserNSMenu : NSMenu
42 {
43 }
44
45 @end // wxPoserNSMenu
46
47 WX_IMPLEMENT_POSER(wxPoserNSMenu);
48 @implementation wxPoserNSMenu : NSMenu
49
50 @end // wxPoserNSMenu
51
52 // ============================================================================
53 // wxCocoaNSMenu implementation
54 // ============================================================================
55 bool wxCocoaNSMenu::CocoaCreate(const wxString &title)
56 {
57     wxAutoNSAutoreleasePool pool;
58     wxLogDebug("CocoaCreate: "+title);
59     m_cocoaNSMenu = [[NSMenu alloc] initWithTitle: [NSString stringWithCString: title.c_str()]];
60     return true;
61 }
62
63 wxCocoaNSMenu::~wxCocoaNSMenu()
64 {
65     [m_cocoaNSMenu release];
66 }
67
68 #endif // wxUSE_MENUS