Re: -outlineView:heightOfRowByItem: gets an item of NULL??
Re: -outlineView:heightOfRowByItem: gets an item of NULL??
- Subject: Re: -outlineView:heightOfRowByItem: gets an item of NULL??
- From: John Stiles <email@hidden>
- Date: Fri, 22 Feb 2008 12:15:37 -0800
OK, that makes sense. My -outlineView:numberOfChildrenOfItem: doesn't do
anything major, just returns the count of an array. I don't foresee any
problems there.
Should I file a doc enhancement bug on this, so this can get in the
docs? The -outlineView:numberOfChildrenOfItem: docs should really have a
warning here, and if there are any other cases, they should be
documented too.
If you can think of any other cases where it would be bad for
-reloadData to get called in a delegate, let me know. I would like to
see it.
Also, would you like a call stack of my NULL-item bug? Would that help
for diagnosing it?
Corbin Dunn wrote:
On Feb 22, 2008, at 11:53 AM, John Stiles wrote:
Is it illegal to call -reloadData from inside a delegate method?
It depends where. If you call -reloadData when
-numberOfChildrenOfItem: is called, then it will mess things up
(basically, that is true for any of the required methods). Basically,
you can imagine why:
for (int i = 0; i < child count; i++) {
(call delegate)
//if it reloaded, then child count may have changed...that can cause
trouble.
}
For the non-required ones, it is less essential. For acceptDrop, it
should be okay, but note that the NSOutlineView doesn't retain the
items, so you'll have to keep that in consideration. Selection change
is also okay. Sorry for the confusion -- I should have been more
specific. Your cases sound okay.
corbin
Because, yeah, when -outlineView:acceptDrop:item:childIndex: is
called, that could easily lead to the whole contents of the outline
view getting rebuilt from scratch. And this could definitely lead to
calls to -reloadData or -reloadItem:reloadChildren:.
If this is going to bite me down the line, what are my options?
Sadly, it's not possible to defer method calls until after
-outlineView:acceptDrop:item:childIndex: returns, due to an AppKit bug:
rdar://5686701 Drag-and-drop from an outline view runs a
run-loop in NSDefaultRunLoopMode
So I don't really know how to work around this bug without going to
extreme lengths.
Please go into a little more detail about what a delegate method can
or cannot do. Right now it's entirely possible, in some corner cases,
that small things like selection-change events (e.g.
-outlineViewSelectionDidChange:) could lead to huge ripple effects
which end up causing the whole window to rebuild itself from scratch.
If that's not kosher, I need to seriously reevaluate a lot of code.
Corbin Dunn wrote:
> It shouldn't ask you for the height of a NULL item.
>
> This is either:
> 1. a bug in nsoutlineview
> 2. your code may be reloading the nsoutlineview in one of the
delegate methods, putting it into a "strange" state. If you see this
happening consistently, you may want to break on NSOutlineView
reloadData and see if it is getting called when it shouldn't be.
>
> corbin
>
> On Feb 21, 2008, at 12:06 PM, John Stiles wrote:
>
>> Fair enough, but the root item is never represented graphically in
a table, so there wouldn't be a need to ask for its row height…?
>> Anyway, I filed a radar… we'll see what happens.
>>
>>
>> Mike Abdullah wrote:
>>> Although the docs don't mention it for this method, quite often
an item of nil is used to represent the tree's root object. I would
suggest therefore returning the default height of a table cell.
>>>
>>> Mike.
>>>
_______________________________________________
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