-
Notifications
You must be signed in to change notification settings - Fork 187
Description
Describe the bug
In certain configurations, a call to getExpanded() returns false on Linux, but true on Windows. The result was seen in eclipse-platform/eclipse.platform.ui#3527, where "dummy" tree items are created on Linux but not on Windows, because JFace believes a tree item to be collapsed when it is not.
To Reproduce
Consider the following snippet:
public static void main(String[] args) {
Shell shell = new Shell();
Tree tree = new Tree(shell, SWT.FULL_SELECTION);
TreeItem item1 = new TreeItem(tree, SWT.NONE);
TreeItem item2 = new TreeItem(item1, SWT.NONE);
item1.setExpanded(true);
System.out.println(item1.getExpanded());
item2.dispose();
System.out.println(item1.getExpanded());
item2 = new TreeItem(item1, SWT.NONE);
System.out.println(item1.getExpanded());
}On Linux, the second call to getExpanded() returns false, because the tree doesn't contain any non-disposed children. However, the item is still expanded, as otherwise the third call would also return false.
On Windows, all calls return true.
In addition, the Linux-implementation of this widget has an isExpanded field that keeps track of the expanded state. This field is true, even though getExpanded() returns false.
Expected behavior
The TreeItem widget should behave consistently across multiple platforms.
Environment:
- Select the platform(s) on which the behavior is seen:
-
- All OS
-
- Windows
-
- Linux
-
- macOS