Skip to content

[Win32] Avoid faulty setting of image list at OS on Tree.setOrientation#3077

Merged
fedejeanne merged 1 commit into
eclipse-platform:masterfrom
vi-eclipse:issue-3075-emptyimage-orientation
Mar 3, 2026
Merged

[Win32] Avoid faulty setting of image list at OS on Tree.setOrientation#3077
fedejeanne merged 1 commit into
eclipse-platform:masterfrom
vi-eclipse:issue-3075-emptyimage-orientation

Conversation

@HeikoKlare
Copy link
Copy Markdown
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
Copy Markdown
Contributor

github-actions Bot commented Feb 11, 2026

Test Results (win32)

   34 files     34 suites   5m 25s ⏱️
4 650 tests 4 577 ✅ 73 💤 0 ❌
1 184 runs  1 160 ✅ 24 💤 0 ❌

Results for commit c012752.

♻️ This comment has been updated with latest results.

@HeikoKlare HeikoKlare force-pushed the issue-3075-emptyimage-orientation branch from 1f2f51a to 658e63b Compare February 12, 2026 16:38
@HeikoKlare HeikoKlare force-pushed the issue-3075-emptyimage-orientation branch from 658e63b to c012752 Compare March 2, 2026 14:35
@HeikoKlare HeikoKlare requested a review from fedejeanne March 2, 2026 14:37
@fedejeanne fedejeanne force-pushed the issue-3075-emptyimage-orientation branch from c012752 to 9bc1593 Compare March 2, 2026 16:03
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 2, 2026

Test Results

  176 files  +   30    176 suites  +30   25m 13s ⏱️ + 2m 26s
4 694 tests +    1  4 672 ✅ +    2   22 💤  -  1  0 ❌ ±0 
6 520 runs  +1 088  6 368 ✅ +1 074  152 💤 +14  0 ❌ ±0 

Results for commit 60ac3a1. ± Comparison against base commit 75beb1e.

♻️ 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
@fedejeanne fedejeanne force-pushed the issue-3075-emptyimage-orientation branch from 33da9ff to 60ac3a1 Compare March 3, 2026 07:42
Copy link
Copy Markdown
Member

@fedejeanne fedejeanne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and works as expected. I added the snippet too.

See also eclipse-platform/www.eclipse.org-eclipse#501

@fedejeanne fedejeanne merged commit 413990a into eclipse-platform:master Mar 3, 2026
23 checks passed
@fedejeanne fedejeanne deleted the issue-3075-emptyimage-orientation branch March 3, 2026 08:12
fedejeanne added a commit to vi-eclipse/eclipse.platform.swt that referenced this pull request Mar 3, 2026
HeikoKlare pushed a commit that referenced this pull request Mar 3, 2026
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

2 participants