diff --git a/mkdocs-website/docs/en/changelog.md b/mkdocs-website/docs/en/changelog.md index 570a25695..c380987a5 100644 --- a/mkdocs-website/docs/en/changelog.md +++ b/mkdocs-website/docs/en/changelog.md @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - [windows] Fixed syso icon file generation bug by [atterpac](https://github.com/atterpac) in [#3675](https://github.com/wailsapp/wails/pull/3675) - [linux] Fix to run natively in wayland incorporated from [#1811](https://github.com/wailsapp/wails/pull/1811) in [#3614](https://github.com/wailsapp/wails/pull/3614) by [@stendler](https://github.com/stendler) +- [windows] Fixed system tray startup panic in [#3693](https://github.com/wailsapp/wails/issues/3693) by [@DeltaLaboratory](https://github.com/DeltaLaboratory) ## v3.0.0-alpha.6 - 2024-07-30 diff --git a/v3/pkg/application/systemtray_windows.go b/v3/pkg/application/systemtray_windows.go index 9262abf06..49354fc7e 100644 --- a/v3/pkg/application/systemtray_windows.go +++ b/v3/pkg/application/systemtray_windows.go @@ -5,11 +5,13 @@ package application import ( "fmt" "syscall" + "time" "unsafe" "github.com/wailsapp/wails/v3/pkg/icons" "github.com/samber/lo" + "github.com/wailsapp/wails/v3/pkg/events" "github.com/wailsapp/wails/v3/pkg/w32" ) @@ -174,8 +176,16 @@ func (s *windowsSystemTray) run() { } nid.CbSize = uint32(unsafe.Sizeof(nid)) - if !w32.ShellNotifyIcon(w32.NIM_ADD, &nid) { - panic(syscall.GetLastError()) + for retries := range 6 { + if !w32.ShellNotifyIcon(w32.NIM_ADD, &nid) { + if retries == 5 { + globalApplication.fatal("Failed to register system tray icon: %v", syscall.GetLastError()) + } + + time.Sleep(500 * time.Millisecond) + continue + } + break } nid.UVersion = w32.NOTIFYICON_VERSION