From 818174238d16970d245a59930f1dfa6c3f9854fa Mon Sep 17 00:00:00 2001 From: "Elie G." Date: Tue, 3 Feb 2026 20:53:20 +0200 Subject: [PATCH] Fix tray icon not appearing on Windows 10 (#350) - Guard tray_enable_dark_mode() with SEH in native code to catch access violations from the undocumented uxtheme.dll ordinal 135 - Catch Throwable (not just Exception) in WindowsTrayManager tray thread - Move initLatch.countDown() into finally block so the calling thread is never deadlocked and can fall back to AWT gracefully --- .../composetray/lib/windows/WindowsTrayManager.kt | 10 +++++++--- winlib | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/commonMain/kotlin/com/kdroid/composetray/lib/windows/WindowsTrayManager.kt b/src/commonMain/kotlin/com/kdroid/composetray/lib/windows/WindowsTrayManager.kt index 9660960..3483956 100644 --- a/src/commonMain/kotlin/com/kdroid/composetray/lib/windows/WindowsTrayManager.kt +++ b/src/commonMain/kotlin/com/kdroid/composetray/lib/windows/WindowsTrayManager.kt @@ -107,17 +107,21 @@ internal class WindowsTrayManager( tray.set(newTray) initialized.set(true) - // Signal that initialization is complete + // Signal that initialization is complete before entering the loop initLatch.countDown() // Run the blocking message loop on this thread runMessageLoop() - } catch (e: Exception) { + } catch (e: Throwable) { log("Error in tray thread: ${e.message}") e.printStackTrace() - initLatch.countDown() // Ensure latch is released even on error } finally { + // Safety net: release latch in case an Error prevented the + // countDown above from being reached. CountDownLatch.countDown() + // is a no-op when the count is already 0, so calling it twice + // on the success path is harmless. + initLatch.countDown() cleanupTray() } }.apply { diff --git a/winlib b/winlib index b78cb80..6a89226 160000 --- a/winlib +++ b/winlib @@ -1 +1 @@ -Subproject commit b78cb8033cd1a2d7ed0a0fe2cd593dad59ba633e +Subproject commit 6a892264367248fe15255f0146766a8002d09543