Skip to content

Commit 93a484e

Browse files
committed
[Win32] Avoid broken UI when DPI change handler fails eclipse-platform#2432
In case a DPI change handler fails with an exception, the complete rescaling process may fail. As an example, it may happen that an image set to an Item has already been disposed when a DPI change event occurs, but the DPI change handler still tries to set that image on the item again, leading to an exception because of the image being disposed. This change ensures that an exception happening when processing a DPI change handler does not result in a complete rescaling failure and instead reports the listener error to the Display. Contributes to eclipse-platform#2432
1 parent 93c0ce9 commit 93a484e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/DPIZoomChangeRegistry.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ public static void applyChange(Widget widget, int newZoom, float scalingFactor)
5353
Class<? extends Widget> clazz = entry.getKey();
5454
DPIZoomChangeHandler handler = entry.getValue();
5555
if (clazz.isInstance(widget)) {
56-
handler.handleDPIChange(widget, newZoom, scalingFactor);
56+
try {
57+
handler.handleDPIChange(widget, newZoom, scalingFactor);
58+
} catch (RuntimeException ex) {
59+
widget.getDisplay().getRuntimeExceptionHandler().accept(ex);
60+
}
5761
}
5862
}
5963
Event event = new Event();

0 commit comments

Comments
 (0)