Re: NSOutlineView blowing stack
Re: NSOutlineView blowing stack
- Subject: Re: NSOutlineView blowing stack
- From: Tom Harrington <email@hidden>
- Date: Thu, 19 Feb 2004 18:04:47 -0700
On Thursday, February 19, 2004, at 05:24 PM, Allan Odgaard wrote:
On 20. Feb 2004, at 1:09, Tom Harrington wrote:
Yes-- I'm tagging each child with a pointer to its parent. The
outline column has a checkbox in it, and clicking the checkbox in one
item may affect the parent item's checkbox state.
Generally I avoid parent pointers -- I have a function which return an
array of parent pointers for a given item which is O(n) rather than
O(1), but I think it is a worthy trade-off due to the simplified
administration of nodes.
I prefer to avoid it as well, but in this case I need to be able to
dereference the parent in -
outlineView:setObjectValue:forTableColumn:byItem:, and having a pointer
value handy helps keep the GUI responsive.
That would seem to be the case, and I suppose collapsing all items
avoids doing such a comparison on an item with a parent reference. I
feel like I'm walking on thin ice here. :-/
A quick fix is to wrap the parent pointers with a NSValue, using
valueWithPointer: and pointerValue to store/retrieve the actual
pointer.
A good idea in any case, prevents it from being a circular reference
and as a nice benefit means I don't have to worry about printing
dictionary descriptions while debugging.
Btw: another problem with cyclic data is that you are causing a
retain loop, and thus the data will never be released (because
children retain parents, so neither will ever get a retain count of
zero). Though it shouldn't crash ;)
Yeah, I'm aware of that risk.
Just to be sure: this is not a risk, this is a guarantee (that the
items will never be freed, unless you manually remove all the parent
pointers).
A poorly-chosen word, I guess. The risk I meant was the risk of driver
error, in this case including not realizing that you had a leak.
--
Tom Harrington
email@hidden
_______________________________________________
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.