From 37b20265146f65a383a74f1adbf6e728f2da5356 Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Sat, 22 Nov 2025 11:10:49 -0500 Subject: [PATCH] throw no more handles if a timer could not be created At the moment the code silently fails on calling timerExec if there are no handles left or it fails for other reasons. Relates to https://github.com/eclipse-platform/eclipse.platform.swt/issues/2806 where we can see that we are running out of handles, but the timerExec does not report a failure. --- .../win32/org/eclipse/swt/widgets/Display.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java index 84b1c94fd7..7b1a3ca9d1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java @@ -4964,6 +4964,7 @@ public T syncCall(SwtCallable callable) throws E * @exception SWTException
    *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  • *
  • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
  • + *
  • ERROR_NO_HANDLES if a handle could not be obtained for timer creation
  • *
* * @see #asyncExec @@ -5005,10 +5006,9 @@ public void timerExec (int milliseconds, Runnable runnable) { } } long newTimerID = OS.SetTimer (hwndMessage, timerId, milliseconds, 0); - if (newTimerID != 0) { - timerList [index] = runnable; - timerIds [index] = newTimerID; - } + if (newTimerID == 0) SWT.error (SWT.ERROR_NO_HANDLES); + timerList [index] = runnable; + timerIds [index] = newTimerID; } boolean translateAccelerator (MSG msg, Control control) {