Skip to content

UI broken after DPI change event #2432

Description

@HeikoKlare

Describe the bug
I ended in a completely broken UI of an Eclipse IDE after changing the scaling of my primary monitor. The DPI change handling failed with an exception:

org.eclipse.swt.SWTException: Graphic is disposed
	at org.eclipse.swt.SWT.error(SWT.java:4946)
	at org.eclipse.swt.SWT.error(SWT.java:4861)
	at org.eclipse.swt.SWT.error(SWT.java:4832)
	at org.eclipse.swt.graphics.Image.getImageData(Image.java:1250)
	at org.eclipse.swt.internal.ImageList.set(ImageList.java:417)
	at org.eclipse.swt.internal.ImageList.getHandle(ImageList.java:342)
	at org.eclipse.swt.widgets.Tree.imageIndex(Tree.java:3754)
	at org.eclipse.swt.widgets.TreeItem.setImage(TreeItem.java:1664)
	at org.eclipse.swt.widgets.TreeItem.setImage(TreeItem.java:1693)
	at org.eclipse.swt.internal.CommonWidgetsDPIChangeHandlers.handleItemDPIChange(CommonWidgetsDPIChangeHandlers.java:46)
	at org.eclipse.swt.internal.DPIZoomChangeRegistry.applyChange(DPIZoomChangeRegistry.java:56)

To Reproduce
I have no reproducer yet, it just happened for me once by now.

Expected behavior
Rescaling on a DPI change (such as when changing primary monitor zoom) should result in a proper UI and, particularly, should not throw an exception.

I see multiple things that need to be done here

  • Find out why this exception occurs at all
  • Check for the image being disposed when setting it on the TreeItem during DPI change handling
  • Embed every DPI change handler into a try/catch to ensure that a failure of a single handler does not lead to a completely (but at most partially) broken UI

Screenshots
Image

Environment:

  1. Select the platform(s) on which the behavior is seen:
    • All OS
    • Windows
    • Linux
    • macOS
  1. Additional OS info (e.g. OS version, Linux Desktop, etc)
    Windows 11

Version since
I20250815-1800

Metadata

Metadata

Assignees

No one assigned

    Labels

    WindowsHappens on Windows OSbugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions