Don't leak associations in wxCocoaDataViewControl

Fix ClearColumns() to release associations between m_OutlineView and
native Cocoa control when re-creating the latter. Previously it only
created a new association, but left the old one with no-deleted native
control in the map.

Fixes #17485.
This commit is contained in:
Václav Slavík
2017-01-05 16:31:46 +01:00
parent 062e3c3d32
commit 2b342e8777
3 changed files with 9 additions and 0 deletions

View File

@@ -343,6 +343,7 @@ public :
FindBestFromWXWidget(WXWidget control);
static void RemoveAssociations( wxWidgetImpl* impl);
static void RemoveAssociation(WXWidget control);
static void Associate( WXWidget control, wxWidgetImpl *impl );

View File

@@ -2084,6 +2084,7 @@ bool wxCocoaDataViewControl::ClearColumns()
// as there is a bug in NSOutlineView version (OSX 10.5.6 #6555162) the
// columns cannot be deleted if there is an outline column in the view;
// therefore, the whole view is deleted and newly constructed:
RemoveAssociation(m_OutlineView); // undo InitOutlineView's association
[m_OutlineView release];
m_OutlineView = [[wxCocoaOutlineView alloc] init];
[((NSScrollView*) GetWXWidget()) setDocumentView:m_OutlineView];

View File

@@ -2739,6 +2739,13 @@ void wxWidgetImpl::RemoveAssociations(wxWidgetImpl* impl)
}
}
void wxWidgetImpl::RemoveAssociation(WXWidget control)
{
wxCHECK_RET( control != NULL, wxT("attempt to remove a NULL WXWidget from control map") );
wxWinMacControlList.erase(control);
}
wxIMPLEMENT_ABSTRACT_CLASS(wxWidgetImpl, wxObject);
wxWidgetImpl::wxWidgetImpl( wxWindowMac* peer , bool isRootControl, bool isUserPane )