Opened 5 months ago

Closed 4 months ago

Last modified 4 months ago

#16210 closed defect (fixed)

wxDataViewCtrl destructor ClearColumns causes a resort wxOSX-Cocoa

Reported by: johnr Owned by: VZ
Priority: normal Milestone: 3.0.1
Component: wxOSX-Cocoa Version: dev-latest
Keywords: wxDataViewCtrl destructor resort Cc: hartwigw
Blocked By: Blocking:
Patch: yes

Description

dataview_osx.cpp destructor for wxDataViewCtrl calls ClearColumns() which in turn calls
GetDataViewPeer()->ClearColumns()
dataview.mm/wxCocoaDataViewControl::ClearColumns()
In this function there is mention of a bug in NSOutlineView for OSX 10.5.6 and the workaround for this is to delete and then recreate the outlineview.
Recreating it calls
-(NSInteger) outlineView:(NSOutlineView*)outlineView numberOfChildrenOfItem:(id)item
which includes the line
if ([sortDescriptors count] > 0)

[children sortUsingFunction:CompareItems context:sortDescriptors];

If there are sortDescriptors then this causes a sort using
NSInteger CompareItems(id item1, id item2, void* context)
in the middle of destroying the wxDataViewCtrl with unexpected results.

I notice a problem when there are 2 wxDataViewCtrls in a notebook and one has had the column header clicked to sort the items.

Not re-creating the outlineView caused a crash so my work around was to call AssociateModel( NULL ) in my derived DataViewCtrl class. However, AssociateModel( NULL ) causes a crash in MSW presumably when wxDataViewCtrlBase::AssociateModel( NULL ) leaves an invalid wxDataViewCtrl::m_notifier which is private.

Probably sortDescriptors should be reset/deleted when clearing columns.

Attachments (1)

dvc_resortdtor.diff download (522 bytes) - added by johnr 5 months ago.

Download all attachments as: .zip

Change History (12)

comment:1 Changed 5 months ago by johnr

This is reproducible in the dataview sample.

1.Run the sample.
2.Click the "title" column header on col 1 of the MyMusicTreeModel so the column resorts and sortDescriptors are created and subsequently set in setSortDescriptors:
3.Set a breakpoint at function
-(NSInteger) outlineView:(NSOutlineView*)outlineView numberOfChildrenOfItem:(id)item
at approx line 679 dataview.mm [children sortUsingFunction:CompareItems context:sortDescriptors];
4.Close the sample so the wxDataViewCtrl is destroyed and the breakpoint will be hit and the CompareItems function will be called.

The sample calls NSInteger CompareItems(id item1, id item2, void* context) in dataview.mm

i.e. A resort of the wxDataViewCtrl is triggered when it is destroyed.
Apart from the inefficiency of performing a sort during destruction of an object it is
a problem when a custom model call back Compare function needs to reference the over-ridden components that are now invalid in the custom DataViewCtrl.

comment:2 Changed 5 months ago by johnr

Objective C isn't my forte but the following diff fixes it for me with no discernable adverse effects. I also expect we probably got a resort on every call to ClearColumns() but I didn't check.

Index: src/osx/cocoa/dataview.mm
===================================================================
--- src/osx/cocoa/dataview.mm	(revision 76432)
+++ src/osx/cocoa/dataview.mm	(working copy)
@@ -2001,6 +2001,11 @@
     // 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:
+    
+    // First remove any sort descriptors so we don't get a sort when
+    // re-building the outlineview
+    [m_OutlineView setSortDescriptors:(nil)];
+    
     [m_OutlineView release];
     m_OutlineView = [[wxCocoaOutlineView alloc] init];
     [((NSScrollView*) GetWXWidget()) setDocumentView:m_OutlineView];
Last edited 5 months ago by johnr (previous) (diff)

comment:3 follow-up: Changed 5 months ago by vadz

  • Milestone set to 3.0.1
  • Patch set

Thanks for the fix! I don't see anything wrong with applying it, but I wonder if it wouldn't be better to avoid recreating anything at all when we're destroyed.

Further, why do we actually need to call ClearColumns() in the dtor at all? Does anything wrong happen if we simply remove this call? In Cocoa, m_OutlineView will still be released in the wxCocoaDataViewControl dtor, so I think it should be enough. I'd prefer to apply this fix to the trunk if it works.

Finally, in the trunk we don't even support 10.5 any more, so we presumably could avoid recreation in ClearColumns(). Stefan, could you please check the status of the (Apple) bug #6555162? If it's fixed now, we don't need all this code at all...

comment:4 Changed 5 months ago by csomor

sorry, that number came from Hartwig's patch 5 years ago, one cannot lookup the status of someone else's rdar and it is not in the openradar.me database

comment:5 Changed 5 months ago by vadz

  • Cc hartwigw added

Sorry, I didn't know the bug numbers were private.

Let's see if Hartwig himself can check its status?

comment:6 Changed 5 months ago by hartwigw

Hi,

according to Apple #6555162 is still open.

Regards,
Hartwig

comment:7 in reply to: ↑ 3 Changed 5 months ago by johnr

Replying to vadz:

I had exactly the same questions.

Thanks for the fix! I don't see anything wrong with applying it, but I wonder if it wouldn't be better to avoid recreating anything at all when we're destroyed.

I tried that but the result was a bad excess crash.

Further, why do we actually need to call ClearColumns() in the dtor at all? Does anything wrong happen if we simply remove this call? In Cocoa, m_OutlineView will still be released in the wxCocoaDataViewControl dtor, so I think it should be enough. I'd prefer to apply this fix to the trunk if it works.

Me too but I was reluctant to mess with something that has been working apart from causing a resort.
Prior to every native column created there is a wxWidget column created. If we remove the ClearColumn call then renderer dtors and wxDataViewColumn dtors don't get called so we would need to replace it with WX_CLEAR_ARRAY(m_ColumnPtrs) to clear the wx columns as ClearColumns does.

I had some memory leaks which bothered me but I need to look at why. Below is a portion of the list but I don't see any difference between using ClearColumns or WX_CLEAR_ARRAY(m_ColumnPtrs) alone.

Leaked Object	#	Address	Size	Responsible Library	Responsible Frame
NSTableHeaderCell	1	0x7fe7c8faae70	96 Bytes	AppKit	-[NSTableColumn initWithIdentifier:]
wxDVCNSTableColumn	1	0x7fe7c8f62310	80 Bytes	xxxx	(anonymous namespace)::CreateNativeColumn(wxDataViewColumn const*)
wxCocoaTableColumn	1	0x7fe7ca3bac10	32 Bytes	AppKit	-[NSCell setFont:]
wxCocoaTableColumn	1	0x7fe7ca3c3660	32 Bytes	AppKit	-[NSCell setFont:]
NSTableHeaderCell	1	0x7fe7ca3babb0	96 Bytes	AppKit	-[NSTableColumn initWithIdentifier:]
NSTableHeaderCell	1	0x7fe7ca3bb1b0	96 Bytes	AppKit	-[NSTableColumn initWithIdentifier:]
wxCocoaTableColumn	1	0x7fe7c8faa840	32 Bytes	AppKit	-[NSCell setFont:]
NSTableHeaderCell	1	0x7fe7ca3b69a0	96 Bytes	AppKit	-[NSTableColumn initWithIdentifier:]
wxCocoaTableColumn	1	0x7fe7c8fabb00	32 Bytes	AppKit	-[NSCell setFont:]
wxCocoaTableColumn	3	< multiple >	192 Bytes	AppKit	-[NSCell _textAttributes]
NSButtonCell	1	0x7fe7ca3b6240	128 Bytes	xxxx	wxDataViewToggleRenderer::wxDataViewToggleRenderer(wxString const&, wxDataViewCellMode, int)

Finally, in the trunk we don't even support 10.5 any more, so we presumably could avoid recreation in ClearColumns(). Stefan, could you please check the status of the (Apple) bug #6555162? If it's fixed now, we don't need all this code at all...

Hartwig confirmed it was still current and I expected it was still current because of the crash I mentioned above when I removed that code before settling for re-setting the sortDescriptors.

I also need to check whether we need to do something about the resort whether or not ClearColumns is called by the dataviewctrl destructor. A straight call to ClearColumns from user code will probably produce the same resort unless AssociateModel(NULL) is used first.

I haven't had time today to follow up today but I will have another look in the next day or so and check the mem leak side of things.

comment:8 Changed 5 months ago by johnr

Ok here is the result. Below is an impressive memory leak report from the dataview sample built with an unaltered trunk. I changed the sample slightly by creating a frame and making the dataview frame a child of the new frame. The dataview frame's dtor is called when it is closed.

I did the above because I do not see these leaks in xcode's instruments tool just by running the sample and closing it. The dataview frame had to be a child of another.

Surprising this has not been noticed before and so I initially wondered whether it was an artifact caused by 'Instruments' but I don't see this with other child frames and dialogs. Looks like the columns are not being deleted despite the workaround in dataview.mm/ClearColumns.

For interest there are about 36 more entries if we don't call ClearColumns() and instead use WX_CLEAR_ARRAY(m_ColumnPtrs)

More work needed...

Leaked Object	#	Address	Size	Responsible Library	Responsible Frame
Malloc 32 Bytes	1	0x102e8bf90	32 Bytes	AppKit	-[NSCell setFont:]
NSCalibratedRGBColor	1	0x102dac250	48 Bytes	AppKit	+[NSColor colorWithCalibratedRed:green:blue:alpha:]
_NSTableColumnAuxiliary	1	0x102e83160	32 Bytes	AppKit	-[NSTableColumn initWithIdentifier:]
NSTextFieldCell	1	0x102e82760	96 Bytes	minimal_cocoa	wxDataViewTextRenderer::wxDataViewTextRenderer(wxString const&, wxDataViewCellMode, int)
wxImageTextCell	1	0x102d70490	144 Bytes	minimal_cocoa	wxDataViewIconTextRenderer::wxDataViewIconTextRenderer(wxString const&, wxDataViewCellMode, int)
NSCellAuxiliary	1	0x102e82e40	80 Bytes	AppKit	-[NSCell initImageCell:]
Malloc 64 Bytes	1	0x1097cc970	64 Bytes	AppKit	-[NSCell _textAttributes]
Malloc 32 Bytes	1	0x102e81de0	32 Bytes	AppKit	-[NSCell setFont:]
NSCellAuxiliary	1	0x102e827c0	80 Bytes	AppKit	-[NSCell initTextCell:]
Malloc 32 Bytes	1	0x102e82a30	32 Bytes	AppKit	-[NSCell setFont:]
_NSTableColumnAuxiliary	1	0x109705c90	32 Bytes	AppKit	-[NSTableColumn initWithIdentifier:]
NSCellAuxiliary	1	0x102d70560	80 Bytes	AppKit	-[NSCell initTextCell:]
__NSDictionaryM	1	0x102dada20	48 Bytes	AppKit	-[NSCell setFont:]
__NSDictionaryM	1	0x102cf5820	48 Bytes	AppKit	-[NSCell setFont:]
NSCellAuxiliary	1	0x102cf1a60	80 Bytes	AppKit	-[NSCell initTextCell:]
__NSDictionaryM	1	0x102cf1ab0	48 Bytes	AppKit	-[NSCell setFont:]
__NSCFString	1	0x109701c00	32 Bytes	Foundation	-[NSPlaceholderString initWithFormat:locale:arguments:]
__NSDictionaryM	1	0x102e81540	48 Bytes	AppKit	-[NSCell setFont:]
wxDVCNSTableColumn	1	0x102e82880	80 Bytes	minimal_cocoa	(anonymous namespace)::CreateNativeColumn(wxDataViewColumn const*)
__NSDictionaryM	1	0x102e74520	48 Bytes	AppKit	-[NSCell setFont:]
NSSnapshotContextSignature	1	0x102dacf80	128 Bytes	AppKit	+[NSCGImageSnapshotRep _lockFocusForCreatingSnapshot:withRect:context:hints:flipped:]
__NSDictionaryM	1	0x109706480	48 Bytes	AppKit	-[NSCell setFont:]
__NSDictionaryM	1	0x109706200	48 Bytes	AppKit	-[NSCell setFont:]
__NSCFString	1	0x102e8b770	32 Bytes	Foundation	-[NSPlaceholderString initWithFormat:locale:arguments:]
NSCellAuxiliary	1	0x102cf6e30	80 Bytes	AppKit	-[NSCell initTextCell:]
Malloc 64 Bytes	1	0x102dadfb0	64 Bytes	AppKit	-[NSCell _textAttributes]
NSCellAuxiliary	1	0x109702570	80 Bytes	AppKit	-[NSCell initTextCell:]
NSCellAuxiliary	1	0x109705d10	80 Bytes	AppKit	-[NSCell initTextCell:]
NSCGImageSnapshotRep	1	0x102daf340	64 Bytes	AppKit	__61+[NSCGImageSnapshotRep unlockFocusCreatingCGImageSnapshotRep]_block_invoke
NSCellAuxiliary	1	0x102cc7c10	80 Bytes	AppKit	-[NSCell initTextCell:]
NSTableHeaderCell	1	0x102e8bf30	96 Bytes	AppKit	-[NSTableColumn initWithIdentifier:]
__NSDictionaryM	1	0x109705d60	48 Bytes	AppKit	-[NSCell setFont:]
_NSTableColumnAuxiliary	1	0x102e82910	32 Bytes	AppKit	-[NSTableColumn initWithIdentifier:]
__NSCFString	1	0x109705430	32 Bytes	Foundation	-[NSPlaceholderString initWithFormat:locale:arguments:]
__NSDictionaryM	1	0x102d70b20	48 Bytes	AppKit	-[NSCell setFont:]
wxDVCNSTableColumn	1	0x102cf5400	80 Bytes	minimal_cocoa	(anonymous namespace)::CreateNativeColumn(wxDataViewColumn const*)
Malloc 32 Bytes	1	0x102e82100	32 Bytes	AppKit	-[NSCell setFont:]
Malloc 32 Bytes	1	0x109702770	32 Bytes	AppKit	-[NSCell setFont:]
NSCellAuxiliary	1	0x102e81750	80 Bytes	AppKit	-[NSCell init]
wxCustomRendererObject	2	< multiple >	32 Bytes	minimal_cocoa	-[wxCustomRendererObject copyWithZone:]
NSButtonCell	1	0x102e815e0	128 Bytes	minimal_cocoa	wxDataViewToggleRenderer::wxDataViewToggleRenderer(wxString const&, wxDataViewCellMode, int)
NSTableHeaderCell	1	0x109705520	96 Bytes	AppKit	-[NSTableColumn initWithIdentifier:]
NSTableHeaderCell	1	0x102e82930	96 Bytes	AppKit	-[NSTableColumn initWithIdentifier:]
__NSDictionaryM	1	0x109702740	48 Bytes	AppKit	-[NSCell setFont:]
NSCellAuxiliary	1	0x109702b80	80 Bytes	AppKit	-[NSCell initTextCell:]
_NSTableColumnAuxiliary	1	0x102daf480	32 Bytes	AppKit	-[NSTableColumn initWithIdentifier:]
wxCustomCell	1	0x1097024d0	96 Bytes	minimal_cocoa	wxDataViewCustomRenderer::wxDataViewCustomRenderer(wxString const&, wxDataViewCellMode, int)
Malloc 32 Bytes	1	0x109705f40	32 Bytes	AppKit	-[NSCell setFont:]
OS_dispatch_source	1	0x102d4faf0	160 Bytes	AppKit	-[NSApplication _installMemoryStatusDispatchSources]
_NSTableColumnAuxiliary	1	0x102e8c0c0	32 Bytes	AppKit	-[NSTableColumn initWithIdentifier:]
__NSDictionaryM	1	0x102e8bb20	48 Bytes	AppKit	-[NSCell setFont:]
Malloc 64 Bytes	6	< multiple >	384 Bytes	AppKit	-[NSCell _textAttributes]
NSCellAuxiliary	1	0x102d70ad0	80 Bytes	AppKit	-[NSCell initTextCell:]
__NSDictionaryM	1	0x1097cbe30	48 Bytes	AppKit	-[NSCell setFont:]
__NSDictionaryM	1	0x102cf5540	48 Bytes	AppKit	-[NSCell setFont:]
_NSTableColumnAuxiliary	1	0x102e745e0	32 Bytes	AppKit	-[NSTableColumn initWithIdentifier:]
wxDVCNSTableColumn	1	0x102e81e20	80 Bytes	minimal_cocoa	(anonymous namespace)::CreateNativeColumn(wxDataViewColumn const*)
NSCellAuxiliary	1	0x102e82990	80 Bytes	AppKit	-[NSCell initTextCell:]
NSCellAuxiliary	1	0x1097cc050	80 Bytes	AppKit	-[NSCell initTextCell:]
Malloc 64 Bytes	1	0x1097cbf70	64 Bytes	AppKit	-[NSCell _textAttributes]
Malloc 64 Bytes	2	< multiple >	128 Bytes	AppKit	-[NSCell _textAttributes]
__NSCFString	1	0x1097cc030	32 Bytes	Foundation	-[NSPlaceholderString initWithFormat:locale:arguments:]
__NSCFString	1	0x102e820e0	32 Bytes	Foundation	-[NSPlaceholderString initWithFormat:locale:arguments:]
NSCellAuxiliary	1	0x102e74660	80 Bytes	AppKit	-[NSCell initTextCell:]
Malloc 64 Bytes	1	0x102dab570	64 Bytes	AppKit	-[NSCell _textAttributes]
NSTextFieldCell	1	0x1097cbd80	96 Bytes	minimal_cocoa	wxDataViewTextRenderer::wxDataViewTextRenderer(wxString const&, wxDataViewCellMode, int)
Malloc 32 Bytes	1	0x102e822e0	32 Bytes	AppKit	-[NSCell setFont:]
__NSCFString	1	0x102e833c0	32 Bytes	minimal_cocoa	wxCFStringRef::wxCFStringRef(wxString const&, wxFontEncoding)
wxDVCNSTableColumn	1	0x102daf3d0	80 Bytes	minimal_cocoa	(anonymous namespace)::CreateNativeColumn(wxDataViewColumn const*)
Malloc 64 Bytes	1	0x102d72260	64 Bytes	AppKit	-[NSCell _textAttributes]
__NSCFString	1	0x1097062c0	32 Bytes	Foundation	-[NSPlaceholderString initWithFormat:locale:arguments:]
NSTableHeaderCell	1	0x109705cb0	96 Bytes	AppKit	-[NSTableColumn initWithIdentifier:]
__NSDictionaryM	1	0x102e746b0	48 Bytes	AppKit	-[NSCell setFont:]
NSImage	1	0x102da69a0	64 Bytes	minimal_cocoa	wxOSXGetNSImageFromCGImage(CGImage*, double)
Malloc 32 Bytes	1	0x102e746e0	32 Bytes	AppKit	-[NSCell setFont:]
NSMutableParagraphStyle	2	< multiple >	192 Bytes	AppKit	-[NSParagraphStyle mutableCopyWithZone:]
NSTableHeaderCell	1	0x102dad970	96 Bytes	AppKit	-[NSTableColumn initWithIdentifier:]
wxDVCNSTableColumn	1	0x102cf2460	80 Bytes	minimal_cocoa	(anonymous namespace)::CreateNativeColumn(wxDataViewColumn const*)
__NSDictionaryM	1	0x102e829e0	48 Bytes	AppKit	-[NSCell setFont:]
Malloc 64 Bytes	1	0x1097cc300	64 Bytes	AppKit	-[NSCell _textAttributes]
_NSTableColumnAuxiliary	1	0x102e81590	32 Bytes	AppKit	-[NSTableColumn initWithIdentifier:]
wxDVCNSTableColumn	1	0x109702a70	80 Bytes	minimal_cocoa	(anonymous namespace)::CreateNativeColumn(wxDataViewColumn const*)
Malloc 64 Bytes	6	< multiple >	384 Bytes	AppKit	-[NSCell _textAttributes]
wxDVCNSTableColumn	1	0x102e8c070	80 Bytes	minimal_cocoa	(anonymous namespace)::CreateNativeColumn(wxDataViewColumn const*)
wxImageTextCell	1	0x102e8c5e0	144 Bytes	minimal_cocoa	wxDataViewIconTextRenderer::wxDataViewIconTextRenderer(wxString const&, wxDataViewCellMode, int)
__NSDictionaryM	1	0x102cc7c60	48 Bytes	AppKit	-[NSCell setFont:]
Malloc 32 Bytes	1	0x102e81570	32 Bytes	AppKit	-[NSCell setFont:]
wxDVCNSTableColumn	1	0x109705490	80 Bytes	minimal_cocoa	(anonymous namespace)::CreateNativeColumn(wxDataViewColumn const*)
Malloc 32 Bytes	1	0x109702d60	32 Bytes	AppKit	-[NSCell setFont:]
__NSCFString	1	0x102cf53a0	32 Bytes	Foundation	-[NSPlaceholderString initWithFormat:locale:arguments:]
__NSDictionaryM	1	0x109702bd0	48 Bytes	AppKit	-[NSCell setFont:]
wxDVCNSTableColumn	1	0x109705c00	80 Bytes	minimal_cocoa	(anonymous namespace)::CreateNativeColumn(wxDataViewColumn const*)
Malloc 64 Bytes	1	0x102d709f0	64 Bytes	AppKit	-[NSCell _textAttributes]
Malloc 64 Bytes	1	0x102d70d70	64 Bytes	AppKit	-[NSCell _textAttributes]
__NSDictionaryM	1	0x1097cc0a0	48 Bytes	AppKit	-[NSCell setFont:]
__NSCFString	1	0x102daae80	32 Bytes	minimal_cocoa	wxCFStringRef::wxCFStringRef(wxString const&, wxFontEncoding)
NSCellAuxiliary	1	0x102e81ce0	80 Bytes	AppKit	-[NSCell initTextCell:]
NSCellAuxiliary	1	0x109706430	80 Bytes	AppKit	-[NSCell initTextCell:]
Malloc 32 Bytes	1	0x102e8c520	32 Bytes	AppKit	-[NSCell setFont:]
NSCellAuxiliary	1	0x102e8bad0	80 Bytes	AppKit	-[NSCell initTextCell:]
wxCustomCell	1	0x102e74470	96 Bytes	minimal_cocoa	wxDataViewCustomRenderer::wxDataViewCustomRenderer(wxString const&, wxDataViewCellMode, int)
NSTableHeaderCell	1	0x1097063b0	96 Bytes	AppKit	-[NSTableColumn initWithIdentifier:]
__NSCFString	2	< multiple >	80 Bytes	minimal_cocoa	wxCFStringRef::wxCFStringRef(wxString const&, wxFontEncoding)
Malloc 32 Bytes	1	0x102e8c010	32 Bytes	AppKit	-[NSCell setFont:]
__NSCFString	1	0x102e731b0	32 Bytes	Foundation	-[NSPlaceholderString initWithFormat:locale:arguments:]
__NSCFString	1	0x102e81680	32 Bytes	minimal_cocoa	wxCFStringRef::wxCFStringRef(wxString const&, wxFontEncoding)
__NSDictionaryM	1	0x102e81d30	48 Bytes	AppKit	-[NSCell setFont:]
Malloc 32 Bytes	1	0x102e74010	32 Bytes	AppKit	-[NSCell setFont:]
NSTableHeaderCell	1	0x102e74600	96 Bytes	AppKit	-[NSTableColumn initWithIdentifier:]
_NSTableColumnAuxiliary	1	0x1097062a0	32 Bytes	AppKit	-[NSTableColumn initWithIdentifier:]
NSCellAuxiliary	1	0x102dad9d0	80 Bytes	AppKit	-[NSCell initTextCell:]
wxCustomCell	1	0x109706150	96 Bytes	minimal_cocoa	wxDataViewCustomRenderer::wxDataViewCustomRenderer(wxString const&, wxDataViewCellMode, int)
_NSTableColumnAuxiliary	1	0x102d70a30	32 Bytes	AppKit	-[NSTableColumn initWithIdentifier:]
NSMutableParagraphStyle	1	0x102d70cf0	96 Bytes	AppKit	-[NSParagraphStyle mutableCopyWithZone:]
__NSDictionaryM	1	0x102e83230	48 Bytes	AppKit	-[NSCell setFont:]
wxDVCNSTableColumn	1	0x102d709a0	80 Bytes	minimal_cocoa	(anonymous namespace)::CreateNativeColumn(wxDataViewColumn const*)
NSTableHeaderCell	1	0x102cf5490	96 Bytes	AppKit	-[NSTableColumn initWithIdentifier:]
Malloc 32 Bytes	1	0x102e82a10	32 Bytes	AppKit	-[NSCell setFont:]
NSTextFieldCell	1	0x102ceeca0	96 Bytes	minimal_cocoa	wxDataViewTextRenderer::wxDataViewTextRenderer(wxString const&, wxDataViewCellMode, int)
NSMutableParagraphStyle	4	< multiple >	384 Bytes	AppKit	-[NSParagraphStyle mutableCopyWithZone:]
NSArray	1	0x102dac590	32 Bytes	AppKit	-[NSImage _replaceRepsWithRep:]
Malloc 32 Bytes	1	0x102e74700	32 Bytes	AppKit	-[NSCell setFont:]
NSCellAuxiliary	1	0x1097055a0	80 Bytes	AppKit	-[NSCell initTextCell:]
NSCellAuxiliary	1	0x1097061b0	80 Bytes	AppKit	-[NSCell initTextCell:]
wxDVCNSTableColumn	1	0x109706320	80 Bytes	minimal_cocoa	(anonymous namespace)::CreateNativeColumn(wxDataViewColumn const*)
NSTableHeaderCell	1	0x102d70a50	96 Bytes	AppKit	-[NSTableColumn initWithIdentifier:]
NSTableHeaderCell	1	0x1097cbfd0	96 Bytes	AppKit	-[NSTableColumn initWithIdentifier:]
NSTableHeaderCell	1	0x102e83180	96 Bytes	AppKit	-[NSTableColumn initWithIdentifier:]
__NSCFString	1	0x102e81e70	32 Bytes	Foundation	-[NSPlaceholderString initWithFormat:locale:arguments:]
wxDVCNSTableColumn	1	0x102e74550	80 Bytes	minimal_cocoa	(anonymous namespace)::CreateNativeColumn(wxDataViewColumn const*)
Malloc 32 Bytes	1	0x102e81fa0	32 Bytes	AppKit	-[NSCell setFont:]
Malloc 32 Bytes	1	0x102e8b710	32 Bytes	AppKit	-[NSCell setFont:]
NSTableHeaderCell	1	0x102e81d80	96 Bytes	AppKit	-[NSTableColumn initWithIdentifier:]
__NSCFString	1	0x102daf460	32 Bytes	Foundation	-[NSPlaceholderString initWithFormat:locale:arguments:]
CGDataProvider	1	0x102db0380	224 Bytes	CoreGraphics	CGTypeCreateInstance
NSCellAuxiliary	1	0x102e744d0	80 Bytes	AppKit	-[NSCell initTextCell:]
wxDVCNSTableColumn	1	0x102e830d0	80 Bytes	minimal_cocoa	(anonymous namespace)::CreateNativeColumn(wxDataViewColumn const*)
_NSImageAuxiliary	1	0x102dace50	80 Bytes	AppKit	-[NSImage _allocAuxiliaryStorage]
NSCellAuxiliary	1	0x102e8c390	80 Bytes	AppKit	-[NSCell initTextCell:]
Malloc 64 Bytes	1	0x102dae050	64 Bytes	AppKit	-[NSCell _textAttributes]
Malloc 32 Bytes	1	0x102e83280	32 Bytes	AppKit	-[NSCell setFont:]
NSTextFieldCell	1	0x102cf6dd0	96 Bytes	minimal_cocoa	wxDataViewTextRenderer::wxDataViewTextRenderer(wxString const&, wxDataViewCellMode, int)
OS_dispatch_source	1	0x102d4fca0	160 Bytes	AppKit	-[NSApplication _installMemoryPressureDispatchSources]
__NSDictionaryM	1	0x102e82810	48 Bytes	AppKit	-[NSCell setFont:]
Malloc 64 Bytes	2	< multiple >	128 Bytes	AppKit	-[NSCell _textAttributes]
__NSCFString	1	0x102d70ab0	32 Bytes	Foundation	-[NSPlaceholderString initWithFormat:locale:arguments:]
NSCustomReleaseData	1	0x102dab8c0	32 Bytes	AppKit	NSNewBitmapBackingStore
__NSCFString	1	0x102e82c00	32 Bytes	Foundation	-[NSPlaceholderString initWithFormat:locale:arguments:]
NSTableHeaderCell	1	0x102cf74f0	96 Bytes	AppKit	-[NSTableColumn initWithIdentifier:]
NSCellAuxiliary	1	0x1097059f0	80 Bytes	AppKit	-[NSCell initImageCell:]
_NSTableColumnAuxiliary	1	0x109702a00	32 Bytes	AppKit	-[NSTableColumn initWithIdentifier:]
_NSTableColumnAuxiliary	1	0x1097cbfb0	32 Bytes	AppKit	-[NSTableColumn initWithIdentifier:]
NSTextFieldCell	1	0x102db04b0	96 Bytes	minimal_cocoa	wxDataViewTextRenderer::wxDataViewTextRenderer(wxString const&, wxDataViewCellMode, int)
__NSDictionaryM	1	0x102d70730	48 Bytes	AppKit	-[NSCell setFont:]
Malloc 64 Bytes	1	0x1097cc880	64 Bytes	AppKit	-[NSCell _textAttributes]
NSLevelIndicatorCell	1	0x102e82d90	176 Bytes	minimal_cocoa	wxDataViewProgressRenderer::wxDataViewProgressRenderer(wxString const&, wxString const&, wxDataViewCellMode, int)
NSCellAuxiliary	1	0x102cf54f0	80 Bytes	AppKit	-[NSCell initTextCell:]
Malloc 32 Bytes	1	0x102e814c0	32 Bytes	AppKit	-[NSCell setFont:]
__NSDictionaryM	1	0x102e8c3e0	48 Bytes	AppKit	-[NSCell setFont:]
__NSCFString	1	0x109705750	32 Bytes	Foundation	-[NSPlaceholderString initWithFormat:locale:arguments:]
wxDVCNSTableColumn	1	0x1097cbf20	80 Bytes	minimal_cocoa	(anonymous namespace)::CreateNativeColumn(wxDataViewColumn const*)
__NSDictionaryM	1	0x102dab1b0	48 Bytes	AppKit	-[NSCell setFont:]
Malloc 64 Bytes	1	0x102daf420	64 Bytes	AppKit	-[NSCell _textAttributes]
NSCellAuxiliary	1	0x1097cbde0	80 Bytes	AppKit	-[NSCell initTextCell:]
__NSCFString	1	0x102f58a70	48 Bytes	Foundation	-[NSPlaceholderString initWithBytes:length:encoding:]
Malloc 32 Bytes	1	0x109702320	32 Bytes	AppKit	-[NSCell setFont:]
NSCellAuxiliary	1	0x102daf380	80 Bytes	AppKit	-[NSCell initTextCell:]
CGImage	1	0x102daf260	224 Bytes	CoreGraphics	CGTypeCreateInstance
Malloc 32 Bytes	1	0x102e73190	32 Bytes	AppKit	-[NSCell setFont:]
__NSDictionaryM	1	0x109704770	48 Bytes	AppKit	-[NSCell setFont:]
_NSTableColumnAuxiliary	1	0x109705410	32 Bytes	AppKit	-[NSTableColumn initWithIdentifier:]
_NSTableColumnAuxiliary	1	0x102cf7630	32 Bytes	AppKit	-[NSTableColumn initWithIdentifier:]
NSCellAuxiliary	1	0x102e831e0	80 Bytes	AppKit	-[NSCell initTextCell:]
Malloc 32 Bytes	1	0x102e83260	32 Bytes	AppKit	-[NSCell setFont:]
_NSTableColumnAuxiliary	1	0x109701460	32 Bytes	AppKit	-[NSTableColumn initWithIdentifier:]
NSTableHeaderCell	1	0x109702b00	96 Bytes	AppKit	-[NSTableColumn initWithIdentifier:]
__NSCFString	1	0x109702a20	32 Bytes	Foundation	-[NSPlaceholderString initWithFormat:locale:arguments:]
NSLevelIndicatorCell	1	0x109705900	176 Bytes	minimal_cocoa	wxDataViewProgressRenderer::wxDataViewProgressRenderer(wxString const&, wxString const&, wxDataViewCellMode, int)
__NSCFString	1	0x102e74840	48 Bytes	minimal_cocoa	wxCFStringRef::wxCFStringRef(wxString const&, wxFontEncoding)

comment:9 Changed 5 months ago by johnr

See #16223 and #16226 for the memory leaks above.

The following diff removes the release and subsequent rebuild of the outlineview that occurred in dataview.mm/ClearColumns during destruction of the wxDataviewCtrl.

OSX bug 6555162 is an inability to delete an outlineview column, i.e. a column with a parent children tree control setup, is still in the current OSX API and is demonstrable in the sample with some alterations. The bug requires the outlineview to be deleted and rebuilt to delete outlineview columns and the use of setDataSource to re-attach the datasource causes a resort.

The patch below exposes another memory leak in the sortDescriptors. See #16231

Index: src/osx/dataview_osx.cpp
===================================================================
--- src/osx/dataview_osx.cpp	(revision 76432)
+++ src/osx/dataview_osx.cpp	(working copy)
@@ -349,7 +349,9 @@
 
 wxDataViewCtrl::~wxDataViewCtrl()
 {
-  ClearColumns();
+  // Clear the wxDataViewColumns here and allow the native columns to be
+  // released with the outlineview
+  WX_CLEAR_ARRAY(m_ColumnPtrs);
 
   // Ensure that the already destructed controls is not notified about changes
   // in the model any more.

Changed 5 months ago by johnr

comment:10 Changed 4 months ago by VZ

  • Owner set to VZ
  • Resolution set to fixed
  • Status changed from new to closed

In 76635:

Don't recreate the native control in wxOSX wxDataViewCtrl dtor.

Don't call ClearColumns() which recreates the control in order to remove its
columns in wxOSX/Cocoa, just clean up the internal data, the control, and its
columns, will soon be deleted anyhow.

Closes #16210.

comment:11 Changed 4 months ago by VZ

In 76639:

Don't recreate the native control in wxOSX wxDataViewCtrl dtor.

Don't call ClearColumns() which recreates the control in order to remove its
columns in wxOSX/Cocoa, just clean up the internal data, the control, and its
columns, will soon be deleted anyhow.

Closes #16210.

Note: See TracTickets for help on using tickets.