Skip to content

Commit

Permalink
Merge pull request getlantern#103 from ldstein/deadlock
Browse files Browse the repository at this point in the history
Fix Deadlock and item ordering in Windows
  • Loading branch information
oxtoacart authored Nov 20, 2019
2 parents a524bd5 + f8538c6 commit 0a49910
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion systray_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,23 @@ func ShowAppWindow(url string) {
func addOrUpdateMenuItem(item *MenuItem) {
action := actions[item.id]
if action == nil {
item.id = atomic.AddInt32(&nextActionId, 1)
item.id = nextActionId
action = walk.NewAction()
action.Triggered().Attach(func() {
// Ensure there is at least one receiver to prevent deadlock
go func() {
select {
case <-item.ClickedCh:
}
}()

item.ClickedCh <- struct{}{}
})
if err := notifyIcon.ContextMenu().Actions().Add(action); err != nil {
fail("Unable to add menu item to systray", err)
}
actions[item.id] = action
atomic.AddInt32(&nextActionId, 1)
}
err := action.SetText(item.title)
if err != nil {
Expand Down

0 comments on commit 0a49910

Please sign in to comment.