Project: Eclipse_Platform_UI
Bug 9262 [Viewers] Recursion with multiple equal elements in IStructuredContentProvider/ITreeContentProvider
Reported: 2002-02-07 12:36:30 | Status: verified wontfix

Currently, IStructuredContentProvider does not restrict the output of getElements(Object input). However, the following code produces a bug: public class MyContentProvider implements TreeContentProvider { ... public Object[] getElements(Object input) { return new Object[] {input}; } } If MyContentProvider is supplied to a TreeViewer, the result is an infinite tree. (The node representing 'input' has one child, which is a node representing 'input', and this situation recurses forever.) It seems that a comparison is being made somewhere so that if a node is equal to the input, getElements is called, otherwise, getChildren is called. So, the array returned by getElements cannot contain the input object. Either the spec on IStructuredContentProvider should be changed to restrict the returned array, or the logic in TreeViewer (and any other viewer with this problem) that determines whether an object is the root or a child should be made more general.

Files changed in fix:
bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/IStructuredContentProvider.java