Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » Caching problem in ObservableCollectionTreeContentProvider.getOrCreateNode(Object,boolean)
Caching problem in ObservableCollectionTreeContentProvider.getOrCreateNode(Object,boolean) [message #1159235] Mon, 28 October 2013 07:36
Erdal Karaca is currently offline Erdal Karaca
Messages: 729
Registered: July 2009
Senior Member
I have the following scenario:
The ObservableCollectionTreeContentProvider caches the same WritableList twice and on dispose of the Viewer, this same WritableList will be disposed twice which will lead to the following exception:

org.eclipse.core.runtime.AssertionFailedException: assertion failed: Getter called on disposed observable org.eclipse.core.databinding.observable.list.WritableList@1d57cdf
	at org.eclipse.core.runtime.Assert.isTrue(Assert.java:110)
	at org.eclipse.core.databinding.observable.ObservableTracker.getterCalled(ObservableTracker.java:252)
	at org.eclipse.core.databinding.observable.list.ObservableList.getterCalled(ObservableList.java:241)
	at org.eclipse.core.databinding.observable.list.ObservableList.hashCode(ObservableList.java:92)
	at java.util.HashMap.removeEntryForKey(Unknown Source)
	at java.util.HashMap.remove(Unknown Source)
	at org.eclipse.jface.internal.databinding.viewers.ObservableCollectionTreeContentProvider$TreeNode.dispose(ObservableCollectionTreeContentProvider.java:491)
	at org.eclipse.jface.internal.databinding.viewers.ObservableCollectionTreeContentProvider$TreeNode.access$0(ObservableCollectionTreeContentProvider.java:489)
	at org.eclipse.jface.internal.databinding.viewers.ObservableCollectionTreeContentProvider.inputChanged(ObservableCollectionTreeContentProvider.java:137)
	at org.eclipse.jface.databinding.viewers.ObservableListTreeContentProvider$Impl.inputChanged(ObservableListTreeContentProvider.java:55)
	at org.eclipse.jface.databinding.viewers.ObservableListTreeContentProvider.inputChanged(ObservableListTreeContentProvider.java:203)
	at org.eclipse.jface.viewers.ContentViewer.handleDispose(ContentViewer.java:171)
	at org.eclipse.jface.viewers.StructuredViewer.handleDispose(StructuredViewer.java:2328)
	at org.eclipse.jface.viewers.ContentViewer$2.widgetDisposed(ContentViewer.java:214)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:123)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
[...]


Internally, org.eclipse.jface.internal.databinding.viewers.ObservableCollectionTreeContentProvider.elementNodes is backed by a HashMap which uses the hashCode() method of the object to be put. Initially, the input of the viewer is an empty WritableList. "Later", the WritableList will be populated by user code and a Viewer.refresh() will be done which makes the WritableList to be added twice as this time the WritableList is not empty and the hashCode() differs.

Bug or wrong usage of the API?
Previous Topic: How change node background color of a disabled Tree-Viewer.
Next Topic:Listen to disposing of a binding?
Goto Forum:
  


Current Time: Tue Jul 29 17:08:44 EDT 2014

Powered by FUDForum. Page generated in 0.03437 seconds