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:
Stefan Csomor
2009-02-09 17:59:37 +00:00
parent 96defed03c
commit be136f0738
3 changed files with 16 additions and 13 deletions

View File

@@ -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,26 +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;
}

View File

@@ -170,6 +170,8 @@ class wxMenuItemCocoaImpl : public wxMenuItemImpl
public :
wxMenuItemCocoaImpl( wxMenuItem* peer, NSMenuItem* item ) : wxMenuItemImpl(peer), m_osxMenuItem(item)
{
if ( ![m_osxMenuItem isSeparatorItem] )
[(wxNSMenuItem*)m_osxMenuItem setImplementation:this];
}
~wxMenuItemCocoaImpl();
@@ -212,6 +214,8 @@ protected :
wxMenuItemCocoaImpl::~wxMenuItemCocoaImpl()
{
if ( ![m_osxMenuItem isSeparatorItem] )
[(wxNSMenuItem*)m_osxMenuItem setImplementation:nil];
}
@@ -253,9 +257,5 @@ wxMenuItemImpl* wxMenuItemImpl::Create( wxMenuItem* peer, wxMenu *pParentMenu,
item = temp;
}
c = new wxMenuItemCocoaImpl( peer, item );
if ( kind != wxITEM_SEPARATOR )
{
[(wxNSMenuItem*)item setImplementation:c];
}
return c;
}

View File

@@ -227,6 +227,7 @@ wxNonOwnedWindowCocoaImpl::wxNonOwnedWindowCocoaImpl()
wxNonOwnedWindowCocoaImpl::~wxNonOwnedWindowCocoaImpl()
{
[m_macWindow setImplementation:nil];
[m_macWindow setDelegate:nil];
[m_macWindow release];
}