Arggg...overrelease in table view cell, but where?
Arggg...overrelease in table view cell, but where?
- Subject: Arggg...overrelease in table view cell, but where?
- From: Randall Meadows <email@hidden>
- Date: Thu, 11 Dec 2008 13:24:42 -0700
Still fighting with the table view custom cell...sorry for the length
of this, I'm trying to include as much info as I can to help you help
me figure this out.
I have subclassed NSTextFieldCell (NSTFC) so that I can do custom
drawing in my table cells (basically multiple text strings within the
cell). My datasource object maintains an NSMutableArray, which gets
populated each time the user selects a something in the rest of the UI.
-numberOfRowsInTableView: simply returns the number of objects in the
array.
-tableView:objectValueForTableColumn:tableColumn:row: simply returns
the object at index "row" of the table.
In -tableView:willDisplayCell:aCellforTableColumn:aTableColumn:row:, I
set a couple of instance variables in my NSTFC subclass using
properties that are set to (readwrite, retain), so they are available
in the -drawInteriorWithFrame:inView: method, such as
aCell.cellObject = [tableValues objectAtIndex:rowIndex];.
I have implemented -copyWithZone in my NSTFC subclass as such:
- (id)copyWithZone:(NSZone *)zone
{
MyTableCell *copy = [super copyWithZone:zone];
copy.cellObject = [self.cellObject copy];
copy.gridController = [self.ViewController copy];
return copy;
}
All the rows fit into the visible area of the table (no scrolling).
Everything fine so far?
I can get it to crash by selecting a third row of the table. First
selection, OK; 2nd selection, OK; 3rd selection, boom:
-[GFController release]: message sent to deallocated instance 0x16d97890
Doesn't happen if I select row 1, then 2, and then 1 again; it has to
be 3 different rows.
Here's the stack trace:
#0 0x94568907 in ___forwarding___
#1 0x94568a12 in __forwarding_prep_0___
#2 0x938c320f in NSPopAutoreleasePool
#3 0x95dc7b8c in -[NSApplication run]
I can also get it to crash with this message: "[GFController name]:
message sent to deallocated instance" simply by resizing the window.
This crash happens in my -tableView:heightOfRow: delegate method.
I have NSZombieEnabled turned on. I'm obviously over-releasing
something, but I've added in a bunch of retains trying to create a
leak, but I'm still stuck with this zombie.
Anyone got any more tips on how to track this down? (I thought I
recalled seeing a pretty good tutorial on how to use NSZombieEnabled
and friends and get a stack trace of where the zombie instance came
from, but now I can't find it. I thought it was part of TN2124, but I
don't see it in there now. For instance, if I turn on
MallocStackLogging, how then do I get the malloc trace?)
Thanks!
randy
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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