Skip to content

Commit 5025718

Browse files
Extend issue #422 TrayToolTip suppression to AppDomain handler
The fix in 562269f added IsTrayToolTipCrash() to OnDispatcherUnhandledException in both apps, but the same race in Hardcodet.NotifyIcon.Wpf can also escape to OnUnhandledException (AppDomain) — observed today when exiting via the tray context menu. The Dispatcher's exception hooks tear down before the tray library finishes processing late tooltip-hide messages, so the exception arrives at AppDomain with no suppression and the user sees a Fatal Error dialog despite the underlying crash being harmless. Mirror the same IsTrayToolTipCrash() check in OnUnhandledException for both Lite and Dashboard. Logs a Warn and returns without showing the dialog. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent b146158 commit 5025718

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

Dashboard/App.xaml.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ protected override void OnExit(ExitEventArgs e)
8989
private void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
9090
{
9191
var exception = e.ExceptionObject as Exception;
92+
93+
/* Silently swallow Hardcodet TrayToolTip race condition (issue #422) when it
94+
escapes the Dispatcher path — happens during tray-Exit shutdown when the
95+
Dispatcher's exception hooks are torn down before the tray library finishes. */
96+
if (exception != null && IsTrayToolTipCrash(exception))
97+
{
98+
Logger.Warning("Suppressed Hardcodet TrayToolTip crash (issue #422) in AppDomain handler");
99+
return;
100+
}
101+
92102
Logger.Fatal("Unhandled AppDomain Exception", exception ?? new Exception("Unknown exception"));
93103

94104
if (e.IsTerminating)

Lite/App.xaml.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,17 @@ public static void LoadAlertSettings()
455455
private void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
456456
{
457457
var exception = e.ExceptionObject as Exception;
458+
459+
/* Silently swallow Hardcodet TrayToolTip race condition (issue #422) when it
460+
escapes the Dispatcher path — happens during tray-Exit shutdown when the
461+
Dispatcher's exception hooks are torn down before the tray library finishes. */
462+
if (exception != null && IsTrayToolTipCrash(exception))
463+
{
464+
AppLogger.Warn("AppDomain", "Suppressed Hardcodet TrayToolTip crash (issue #422)");
465+
AppLogger.Flush();
466+
return;
467+
}
468+
458469
AppLogger.Error("AppDomain", "Unhandled exception (terminating=" + e.IsTerminating + ")", exception);
459470
AppLogger.Flush();
460471

0 commit comments

Comments
 (0)