Skip to content

Commit b184087

Browse files
LinlcccMrJul
authored andcommitted
Fix hidden Win32 TrayIcon appearing after icon updates Preserve the current tray icon registration state when updating its icon, so a hidden TrayIcon remains hidden until SetIsVisible(true) is called. (AvaloniaUI#22125)
1 parent 3e017d0 commit b184087

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/Windows/Avalonia.Win32/TrayIconImpl.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public void SetIcon(IWindowIconImpl? icon)
9494
{
9595
_iconImpl = (IconImpl?)icon;
9696
_iconStale = true;
97-
UpdateIcon();
97+
UpdateIcon(!_iconAdded);
9898
}
9999

100100
/// <inheritdoc />
@@ -376,6 +376,10 @@ protected virtual void Dispose(bool disposing)
376376
if (!_disposedValue)
377377
{
378378
UpdateIcon(true);
379+
380+
s_trayIcons.Remove(_uniqueId);
381+
_icon?.Dispose();
382+
_icon = null;
379383

380384
_disposedValue = true;
381385
}

0 commit comments

Comments
 (0)