Skip to content

Conversation

@HeikoKlare
Copy link
Contributor

@HeikoKlare HeikoKlare commented Feb 11, 2026

The Windows Tree implementation only registers an image list at the OS control in case an image is set in the first column of an item of the tree. For images in the other columns, they are added to an SWT image list but since the images are embedded by SWT, no image list is registered at the OS.
The implementation of Tree.updateOrientation() does not consider that for the OS control no image list may have been set even if the SWT control manages an image list. As a consequence, calling Tree.setOrientation() on a Tree whose items do not have any image in the first column leads to all those items receiving a white space where an image might be placed as an empty image list is registered at the OS.

This change adapts the Tree.updateOrientation() implementation to only refresh the OS image list for the control in case one was already set before. In addition to calling Tree.setOrientation() this also affects DPI changes when moving the containing shell to a monitor with a different zoom where the same happens because of a call to Tree.updateOrientation().

Fixes #3075

How to reproduce

Execute this snippet:

	public static void main(String[] args) {
		Display display = new Display();
		Shell shell = new Shell(display);
		shell.setLayout(new FillLayout());

		Tree tree = new Tree(shell, SWT.BORDER | SWT.FULL_SELECTION);
		tree.setLinesVisible(true);
		TreeColumn column1 = new TreeColumn(tree, SWT.NONE);
		column1.setWidth(200);
		TreeColumn column2 = new TreeColumn(tree, SWT.NONE);
		column2.setWidth(200);

		Image image = new Image(display, Snippet392.class.getResourceAsStream("eclipse.svg"));

		TreeItem item = new TreeItem(tree, SWT.None);
		item.setText(0, "Hello");
		item.setText(1, "World");
		item.setImage(1, image);
		new TreeItem(item, SWT.None);

		tree.setOrientation(SWT.LEFT_TO_RIGHT);
		shell.setSize(600, 150);
		shell.open();

		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}

		display.dispose();
	}

With the current code state it gives:
image

With this change (and without the call to tree.setOrientation()) it gives:
image

@github-actions
Copy link
Contributor

github-actions bot commented Feb 11, 2026

Test Results (win32)

   34 files     34 suites   4m 46s ⏱️
4 649 tests 4 576 ✅ 73 💤 0 ❌
  174 runs    171 ✅  3 💤 0 ❌

Results for commit 658e63b.

♻️ This comment has been updated with latest results.

The Windows Tree implementation only registers an image list at the OS
control in case an image is set in the first column of an item of the
tree. For images in the other columns, they are added to an SWT image
list but since the images are embedded by SWT, no image list is
registered at the OS.
The implementation of Tree.updateOrientation() does not consider that
for the OS control no image list may have been set even if the SWT
control manages an image list. As a consequence, calling
Tree.setOrientation() on a Tree whose items do not have any image in the
first column leads to all those items receiving a white space where an
image might be placed as an empty image list is registered at the OS.

This change adapts the Tree.updateOrientation() implementation to only
refresh the OS image list for the control in case one was already set
before. In addition to calling Tree.setOrientation() this also affects
DPI changes when moving the containing shell to a monitor with a
different zoom where the same happens because of a call to
Tree.updateOrientation().

Contributes to
eclipse-platform#3075
@HeikoKlare HeikoKlare force-pushed the issue-3075-emptyimage-orientation branch from 1f2f51a to 658e63b Compare February 12, 2026 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Images of trees in a non-first column disappear upon DPI change [Windows] [Tree] Column icons and text overlaps in multi resolution monitor setup

1 participant