From 1f2f51a9257a788ad9a7ae7e7f13d4087d2b9944 Mon Sep 17 00:00:00 2001 From: "Klare, Heiko" Date: Wed, 11 Feb 2026 14:42:30 +0100 Subject: [PATCH] [Win32] Avoid faulty setting of image list at OS on Tree.setOrientation 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 https://github.com/eclipse-platform/eclipse.platform.swt/issues/3075 --- .../Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java index 560d89121f..98654ee56b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java @@ -5805,8 +5805,12 @@ void updateOrientation () { } } } - long hImageList = imageList.getHandle(getAutoscalingZoom()); - OS.SendMessage (handle, OS.TVM_SETIMAGELIST, OS.TVSIL_NORMAL, hImageList); + // Image list is only set at OS when the first column contains images, + // thus check if an image list is set at the OS to refresh and otherwise skip it + if (OS.SendMessage (handle, OS.TVM_GETIMAGELIST, OS.TVSIL_NORMAL, 0) != 0) { + long hImageList = imageList.getHandle(getAutoscalingZoom()); + OS.SendMessage (handle, OS.TVM_SETIMAGELIST, OS.TVSIL_NORMAL, hImageList); + } } if (hwndHeader != 0) { if (headerImageList != null) {