Skip to content

Commit

Permalink
add retry mechanism for create shell notification icon
Browse files Browse the repository at this point in the history
  • Loading branch information
DeltaLaboratory committed Aug 20, 2024
1 parent fbcce0b commit 51fd0b2
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions v3/pkg/application/systemtray_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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 4 {
if !w32.ShellNotifyIcon(w32.NIM_ADD, &nid) {
if retries == 3 {
panic(syscall.GetLastError())
}

time.Sleep(2 * time.Second)
continue
}
break
}

nid.UVersion = w32.NOTIFYICON_VERSION
Expand Down

0 comments on commit 51fd0b2

Please sign in to comment.