diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java index 8aac323cd12..f516fe8b4fe 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java @@ -6062,10 +6062,15 @@ private DPIChangeProcessingCallback(Control control, Runnable dpiChangeProcessin // Has to have TIMERPROC signature, see https://learn.microsoft.com/en-us/windows/win32/api/winuser/nc-winuser-timerproc Callback callback = new Callback(this, "run", void.class, new Type[] { int.class, int.class, int.class, int.class} ); this.operation = () -> { - if (!control.isDisposed()) { - dpiChangeProcessing.run(); + try { + if (!control.isDisposed()) { + dpiChangeProcessing.run(); + } + } finally { + // The callback must be released in any case, as callback slots are a + // limited resource and leaking them makes further scheduling fail + callback.dispose(); } - callback.dispose(); }; this.address = callback.getAddress(); }