From 62d1bb7357717f2668a55232bfd7f7365fef7bad Mon Sep 17 00:00:00 2001 From: Myles Horton Date: Mon, 20 Apr 2020 13:43:11 -0700 Subject: [PATCH] check if the menu item is nil --- systray.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/systray.go b/systray.go index d433173..b4970d5 100644 --- a/systray.go +++ b/systray.go @@ -171,8 +171,12 @@ func (item *MenuItem) update() { func systrayMenuItemSelected(id int32) { menuItemsLock.RLock() - item := menuItems[id] + item, ok := menuItems[id] menuItemsLock.RUnlock() + if !ok { + log.Errorf("No menu item with ID %v", id) + return + } select { case item.ClickedCh <- struct{}{}: // in case no one waiting for the channel