make sure no delegates/impl ptrs are still set during destruction
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58815 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -39,6 +39,7 @@
|
|||||||
- (id) init
|
- (id) init
|
||||||
{
|
{
|
||||||
[super init];
|
[super init];
|
||||||
|
impl = NULL;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,8 +124,15 @@
|
|||||||
class wxMenuCocoaImpl : public wxMenuImpl
|
class wxMenuCocoaImpl : public wxMenuImpl
|
||||||
{
|
{
|
||||||
public :
|
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();
|
virtual ~wxMenuCocoaImpl();
|
||||||
@@ -181,26 +189,20 @@ public :
|
|||||||
static wxMenuImpl* Create( wxMenu* peer, const wxString& title );
|
static wxMenuImpl* Create( wxMenu* peer, const wxString& title );
|
||||||
static wxMenuImpl* CreateRootMenu( wxMenu* peer );
|
static wxMenuImpl* CreateRootMenu( wxMenu* peer );
|
||||||
protected :
|
protected :
|
||||||
NSMenu* m_osxMenu;
|
wxNSMenu* m_osxMenu;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
wxMenuCocoaImpl::~wxMenuCocoaImpl()
|
wxMenuCocoaImpl::~wxMenuCocoaImpl()
|
||||||
{
|
{
|
||||||
[m_osxMenu setDelegate:nil];
|
[m_osxMenu setDelegate:nil];
|
||||||
|
[m_osxMenu setImplementation:nil];
|
||||||
[m_osxMenu release];
|
[m_osxMenu release];
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMenuImpl* wxMenuImpl::Create( wxMenu* peer, const wxString& title )
|
wxMenuImpl* wxMenuImpl::Create( wxMenu* peer, const wxString& title )
|
||||||
{
|
{
|
||||||
static wxNSMenuController* controller = NULL;
|
|
||||||
if ( controller == NULL )
|
|
||||||
{
|
|
||||||
controller = [[wxNSMenuController alloc] init];
|
|
||||||
}
|
|
||||||
wxCFStringRef cfText( title );
|
wxCFStringRef cfText( title );
|
||||||
wxNSMenu* menu = [[wxNSMenu alloc] initWithTitle:cfText.AsNSString()];
|
wxNSMenu* menu = [[wxNSMenu alloc] initWithTitle:cfText.AsNSString()];
|
||||||
wxMenuImpl* c = new wxMenuCocoaImpl( peer, menu );
|
wxMenuImpl* c = new wxMenuCocoaImpl( peer, menu );
|
||||||
[menu setDelegate:controller];
|
|
||||||
[menu setImplementation:c];
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
@@ -170,6 +170,8 @@ class wxMenuItemCocoaImpl : public wxMenuItemImpl
|
|||||||
public :
|
public :
|
||||||
wxMenuItemCocoaImpl( wxMenuItem* peer, NSMenuItem* item ) : wxMenuItemImpl(peer), m_osxMenuItem(item)
|
wxMenuItemCocoaImpl( wxMenuItem* peer, NSMenuItem* item ) : wxMenuItemImpl(peer), m_osxMenuItem(item)
|
||||||
{
|
{
|
||||||
|
if ( ![m_osxMenuItem isSeparatorItem] )
|
||||||
|
[(wxNSMenuItem*)m_osxMenuItem setImplementation:this];
|
||||||
}
|
}
|
||||||
|
|
||||||
~wxMenuItemCocoaImpl();
|
~wxMenuItemCocoaImpl();
|
||||||
@@ -212,6 +214,8 @@ protected :
|
|||||||
|
|
||||||
wxMenuItemCocoaImpl::~wxMenuItemCocoaImpl()
|
wxMenuItemCocoaImpl::~wxMenuItemCocoaImpl()
|
||||||
{
|
{
|
||||||
|
if ( ![m_osxMenuItem isSeparatorItem] )
|
||||||
|
[(wxNSMenuItem*)m_osxMenuItem setImplementation:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -253,9 +257,5 @@ wxMenuItemImpl* wxMenuItemImpl::Create( wxMenuItem* peer, wxMenu *pParentMenu,
|
|||||||
item = temp;
|
item = temp;
|
||||||
}
|
}
|
||||||
c = new wxMenuItemCocoaImpl( peer, item );
|
c = new wxMenuItemCocoaImpl( peer, item );
|
||||||
if ( kind != wxITEM_SEPARATOR )
|
|
||||||
{
|
|
||||||
[(wxNSMenuItem*)item setImplementation:c];
|
|
||||||
}
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
@@ -227,6 +227,7 @@ wxNonOwnedWindowCocoaImpl::wxNonOwnedWindowCocoaImpl()
|
|||||||
|
|
||||||
wxNonOwnedWindowCocoaImpl::~wxNonOwnedWindowCocoaImpl()
|
wxNonOwnedWindowCocoaImpl::~wxNonOwnedWindowCocoaImpl()
|
||||||
{
|
{
|
||||||
|
[m_macWindow setImplementation:nil];
|
||||||
[m_macWindow setDelegate:nil];
|
[m_macWindow setDelegate:nil];
|
||||||
[m_macWindow release];
|
[m_macWindow release];
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user