Fix deadlock on Windows on menu item click

This commit is contained in:
leo.steiner
2019-11-20 15:37:35 +08:00
parent 1a6b33f303
commit b50ed9ab74
+7
View File
@@ -125,6 +125,13 @@ func addOrUpdateMenuItem(item *MenuItem) {
item.id = atomic.AddInt32(&nextActionId, 1)
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 {