PDFOutline memory management
PDFOutline memory management
- Subject: PDFOutline memory management
- From: "Adam R. Maxwell" <email@hidden>
- Date: Mon, 16 Apr 2007 20:39:17 -0700
I was checking over some code for memory leaks with MallocDebug, and
discovered an NSOutlineView datasource method that retains an object
from a PDFOutline instance variable before returning it, but never
releases it. Removing the retains causes a crash, and I notice that
Apple's sample code
http://developer.apple.com/samplecode/PDFKitLinker2/listing11.html
has a similar implementation (in fact, I think ours was originally
copied from it). Note the retains which are never balanced out
AFAICT. I've thought of just sticking each child in a set before it's
returned, then just releasing the set in -dealloc, but I'd like to
know if I'm overlooking something obvious.
- (id) outlineView: (NSOutlineView *) outlineView child: (int) index
ofItem: (id) item
{
if (item == NULL) {
if ((_outline) && ([[_pdfView document] isLocked] == NO))
return [[_outline childAtIndex: index] retain];
else
return NULL;
}
else
return [[(PDFOutline *)item childAtIndex: index] retain];
}
thanks,
Adam
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden