Re: Crash when sorting tree bound to NSOutlineView
Re: Crash when sorting tree bound to NSOutlineView
- Subject: Re: Crash when sorting tree bound to NSOutlineView
- From: Markus Spoettl <email@hidden>
- Date: Sun, 28 Dec 2008 17:33:47 -0800
On Dec 27, 2008, at 11:19 AM, Markus Spoettl wrote:
The crash goes away. However, I have a feeling that this may be pure
coincidence. Even more so as the crash also goes way if the node
inserted is not on that particular location in the tree or if
another node gets inserted somewhere else first. All very strange.
This of course turned out to be a fluke and the crash reappeared
promptly with a slightly different tree configuration.
Turns out - not very surprisingly - that I'm doing something that the
outline doesn't like: The outline view is bound via a NSTreeController
and I'm observing the controller's -arrangedObjects property. When a
KVO notification is delivered, I go through the outline and expand
certain nodes. This all works well except for when the tree gets
sorted. This causes an KVO notification but apparently the outline
doesn't like to get its tree nodes expanded at this stage.
I've done some digging with NSZombieEnabled and CFZombieLevel and it
appears that NSOutlineView releases an internal treenode due to the
sorting which is still accessible (but garbage) via -itemAtRow: When
this happens I get this console entry
12/28/08 1:38:37 PM myApp[8993] *** -[NSTreeControllerTreeNode
retain]: message sent to deallocated instance 0x166e0920
In the course of debugging this I also got assertions in AppKit:
12/28/08 12:41:54 PM myApp[8615] *** Assertion failure in -
[_NSBindingAdaptor outlineColumn:willDisplayCell:row:], /SourceCache/
AppKit/AppKit-949.43/Binding.subproj/_NSBindingAdaptor.m:759
I guess I can understand that things get complicated when you mess
with the expanded items during a sort which changes the nodes
arrangements. Fair enough.
The question is how can I ensure a certain node stays expanded when
its root nodes array gets sorted programatically. Apparently
NSOutlineView throws away all the nodes that are being sorted and
creates new ones which makes it loose the expanded state.
Hints appreciated!
Regards
Markus
--
__________________________________________
Markus Spoettl
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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