Re: NSOutlineView Problem
Re: NSOutlineView Problem
- Subject: Re: NSOutlineView Problem
- From: Scott Ahten <email@hidden>
- Date: Thu, 10 Jun 2004 00:01:48 -0400
On Jun 9, 2004, at 4:44 PM, Andreas Mayer wrote:
Am 09.06.2004 um 21:08 schrieb Scott Ahten:
When is it safe to release the objects returned to an NSOutlineView
in outlineView:child:ofItem?
When you don't need the outline view anymore?
If it was only that simple :)
My data source asks the item (XMLTree
http://iharder.net/macosx/xmltree/ ) for it's child at the requested
index and returns it. The object is created by the item and I pass it
on to the outline view when requested.
// Simplified version of the method...
- (id)outlineView:(NSOutlineView *)ov child:(int)index ofItem:(id)item
{
XMLTree * childTree;
// is the parent non-nil?
if (item) {
childTree = [item childAtIndex:index];
} else {
// Else return the root
childTree = [docTree childAtIndex:1];
}
return [childTree retain];
}
Looking at the source for childAtIndex, the item creates a new XMLTree
based on the child node (a CFXMLTreeRef) and returns it autoreleased.
Since the outline view calls this method multiple times for the same
child, multiple versions of same child are created.
Retaining each child before returning it to the outline view causes a
memory leak because they never get released. Attempts to return the
child autoreleased results in a crash.
Andreas
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
- - - - -
:: email@hidden
::
http://www.pixelfreak.net
- - - - -
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.