From f3c7bcfdc09916e2cd555e5c5f0527087936659b Mon Sep 17 00:00:00 2001 From: Bastian Eicher Date: Sat, 8 Jul 2023 18:09:54 +0200 Subject: [PATCH] GuiCommandHandler: Catch exceptions when showing notifications --- .../GuiCommandHandler.Notifications.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Commands.WinForms/GuiCommandHandler.Notifications.cs b/src/Commands.WinForms/GuiCommandHandler.Notifications.cs index 412a3feef..709305dc5 100644 --- a/src/Commands.WinForms/GuiCommandHandler.Notifications.cs +++ b/src/Commands.WinForms/GuiCommandHandler.Notifications.cs @@ -48,8 +48,17 @@ protected override void DisplayLogEntry(LogSeverity severity, string message) private void ShowNotification(string title, string message, ToolTipIcon icon = ToolTipIcon.None) { void Classic() - => new NotifyIcon {Visible = true, Text = Branding.Name ?? "Zero Install", Icon = Branding.Icon} - .ShowBalloonTip(10000, title, message, icon); + { + try + { + new NotifyIcon {Visible = true, Text = Branding.Name ?? "Zero Install", Icon = Branding.Icon} + .ShowBalloonTip(10000, title, message, icon); + } + catch (Win32Exception) + { + // Notifications are only shown with best effort + } + } void Modern(string appId) {