[Webkit-unassigned] [Bug 8850] cocoa bindings - crash when DOM nodes are deleted while NSTreeController+NSTableView are bound

bugzilla-daemon at opendarwin.org bugzilla-daemon at opendarwin.org
Wed Jul 5 15:20:24 PDT 2006


http://bugzilla.opendarwin.org/show_bug.cgi?id=8850





------- Comment #18 from speth at end.com  2006-07-05 15:20 PDT -------
>From what I can tell (BindingAdaptors and NSTreeController internals are still
a black box outside of Infinite Loop), the crash occurs because the
NSOutlineView does not retain the values that it displays.  It expects the data
to be there until the model notifies it (through KVO messages to the
controller) that the values are changing.  So it doesn't matter, in this case,
that the nodes are refcounted.  If we are going to change the model behind the
scenes, using non-KVO methods (i.e. the DOM manipulation API), then we're
obligated to tell it when the value for the children key path is changing. 
That's why this crash and the notification of childNodes changing are tightly
related.

Also, addressing some of the issues raised in comment #14:

> I suspect it's a bug that every call to childNodes produces a distinct DOMNodeList.

I agree that it's probably a bug that calling childNodes generates a unique
DOMNodeList each time.  Can someone confirm that this is not the desired
behavior?  If so, it should go into a new bug, since it is not really related
to this (except by my using it to make a weak argument).

> I'd think it would be straightforward to wrap the DOMNodeList in something that is a dynamic
> NSArray rather than allocating a static NSArray.

This is exactly what this patch does:  [DOMNode valueForKey:@"childNodes"] gets
special-cased to return [[DOMNode childNodes] valueForKey:@"items"].  What this
does (in conjunction with the DOMNodeList's countOfItems/objectInItemsAtIndex:
accessors) is generate an NSKeyValueArray for the childNodes list.  The KVO
machinery generates this for us automatically, and it works just like we'd want
it to.  NSKeyValueArray is exactly what you describe.. an NSArray subclass that
is a KVO compliant proxy for an array-like object, which dynamically generates
calls to the original object (the DOMNodeList).

On further consideration, I don't like how this patch special-cases the KVC
access of childNodes to return the NSKeyValueArray instead of a DOMNodeList.  I
think childNodes should return a DOMNodeList and there should be a new key for
accessing the array, perhaps "childNodesArray"?

Finally, on the topic of whether to send notifications for the DOMNodeList as a
whole or individual notifications for its contents, I agree that it would be
nice to support the finer grained KVO messages for to-many relationships, but
it's unnecessary here.  By substituting a logging proxy in place of the
childNodes value, I've seen that the tree controller does not observe any
properties of the child nodes object.  the Node's children key path is
observed, and when changed, the subtree is recomputed.  we could add the
further notifications for completeness, but the controller isn't listening.


-- 
Configure bugmail: http://bugzilla.opendarwin.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the webkit-unassigned mailing list