From b50ed9ab746d65b73e10d69f1a05fac1c4baf5a5 Mon Sep 17 00:00:00 2001 From: "leo.steiner" Date: Wed, 20 Nov 2019 15:37:35 +0800 Subject: [PATCH] Fix deadlock on Windows on menu item click --- systray_windows.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/systray_windows.go b/systray_windows.go index 4f8e731..859475f 100644 --- a/systray_windows.go +++ b/systray_windows.go @@ -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 {