• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSOutlineView Problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


  • Follow-Ups:
    • Re: NSOutlineView Problem
      • From: John Terranova <email@hidden>
References: 
 >NSOutlineView Problem (From: Scott Ahten <email@hidden>)
 >Re: NSOutlineView Problem (From: Andreas Mayer <email@hidden>)

  • Prev by Date: Re: Word count
  • Next by Date: newbie questions about objective-c, ruby, python, groovy and cocoa
  • Previous by thread: Re: NSOutlineView Problem
  • Next by thread: Re: NSOutlineView Problem
  • Index(es):
    • Date
    • Thread