Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to addOrUpdateMenuItem: Invalid menu handle #184

Open
d1y opened this issue Nov 17, 2020 · 2 comments
Open

Unable to addOrUpdateMenuItem: Invalid menu handle #184

d1y opened this issue Nov 17, 2020 · 2 comments

Comments

@d1y
Copy link

d1y commented Nov 17, 2020

my Mac test is OK

Error report in Windows :(

image

PS C:\Users\望天\cat\inettray> go run .
ERROR systray: systray_windows.go:908 Unable to addOrUpdateMenuItem: Invalid menu handle. [error=Unable to addOrUpdateMenuItem: %v error_location=github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908) error_op= error_text=Unable to addOrUpdateMenuItem: Invalid menu handle. error_type=errors.Error]
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.(*MenuItem).update (systray.go:194)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.AddMenuItem (systray.go:116)
ERROR systray: systray_windows.go:908   at main.onReady (main.go:32)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.Register.func2 (systray.go:91)
ERROR systray: systray_windows.go:908   at runtime.goexit (asm_amd64.s:1374)
ERROR systray: systray_windows.go:908 Caused by: Invalid menu handle.
ERROR systray: systray_windows.go:908 Unable to addOrUpdateMenuItem: Invalid menu handle. [error=Unable to addOrUpdateMenuItem: %v error_location=github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908) error_op= error_text=Unable to addOrUpdateMenuItem: Invalid menu handle. error_type=errors.Error]
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.(*MenuItem).update (systray.go:194)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.(*MenuItem).AddSubMenuItem (systray.go:129)
ERROR systray: systray_windows.go:908   at main.onReady (main.go:33)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.Register.func2 (systray.go:91)
ERROR systray: systray_windows.go:908   at runtime.goexit (asm_amd64.s:1374)
ERROR systray: systray_windows.go:908 Caused by: Invalid menu handle.
ERROR systray: systray_windows.go:908 Unable to addOrUpdateMenuItem: Invalid menu handle. [error=Unable to addOrUpdateMenuItem: %v error_location=github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908) error_op= error_text=Unable to addOrUpdateMenuItem: Invalid menu handle. error_type=errors.Error]
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.(*MenuItem).update (systray.go:194)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.(*MenuItem).AddSubMenuItem (systray.go:129)
ERROR systray: systray_windows.go:908   at main.onReady (main.go:34)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.Register.func2 (systray.go:91)
ERROR systray: systray_windows.go:908   at runtime.goexit (asm_amd64.s:1374)
ERROR systray: systray_windows.go:908 Caused by: Invalid menu handle.
ERROR systray: systray_windows.go:908 Unable to addOrUpdateMenuItem: Invalid menu handle. [error=Unable to addOrUpdateMenuItem: %v error_location=github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908) error_op= error_text=Unable to addOrUpdateMenuItem: Invalid menu handle. error_type=errors.Error]
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.(*MenuItem).update (systray.go:194)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.(*MenuItem).AddSubMenuItem (systray.go:129)
ERROR systray: systray_windows.go:908   at main.onReady (main.go:35)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.Register.func2 (systray.go:91)
ERROR systray: systray_windows.go:908   at runtime.goexit (asm_amd64.s:1374)
ERROR systray: systray_windows.go:908 Caused by: Invalid menu handle.
ERROR systray: systray_windows.go:908 Unable to addOrUpdateMenuItem: Invalid menu handle. [error=Unable to addOrUpdateMenuItem: %v error_location=github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908) error_op= error_text=Unable to addOrUpdateMenuItem: Invalid menu handle. error_type=errors.Error]
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.(*MenuItem).update (systray.go:194)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.(*MenuItem).AddSubMenuItem (systray.go:129)
ERROR systray: systray_windows.go:908   at main.onReady (main.go:36)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.Register.func2 (systray.go:91)
ERROR systray: systray_windows.go:908   at runtime.goexit (asm_amd64.s:1374)
ERROR systray: systray_windows.go:908 Caused by: Invalid menu handle.
ERROR systray: systray_windows.go:908 Unable to addOrUpdateMenuItem: Invalid menu handle. [error=Unable to addOrUpdateMenuItem: %v error_location=github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908) error_op= error_text=Unable to addOrUpdateMenuItem: Invalid menu handle. error_type=errors.Error]
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.(*MenuItem).update (systray.go:194)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.(*MenuItem).AddSubMenuItem (systray.go:129)
ERROR systray: systray_windows.go:908   at main.onReady (main.go:37)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.Register.func2 (systray.go:91)
ERROR systray: systray_windows.go:908   at runtime.goexit (asm_amd64.s:1374)
ERROR systray: systray_windows.go:908 Caused by: Invalid menu handle.
ERROR systray: systray_windows.go:908 Unable to addOrUpdateMenuItem: Invalid menu handle. [error=Unable to addOrUpdateMenuItem: %v error_location=github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908) error_op= error_text=Unable to addOrUpdateMenuItem: Invalid menu handle. error_type=errors.Error]
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.(*MenuItem).update (systray.go:194)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.(*MenuItem).AddSubMenuItem (systray.go:129)
ERROR systray: systray_windows.go:908   at main.onReady (main.go:38)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.Register.func2 (systray.go:91)
ERROR systray: systray_windows.go:908   at runtime.goexit (asm_amd64.s:1374)
ERROR systray: systray_windows.go:908 Caused by: Invalid menu handle.
ERROR systray: systray_windows.go:908 Unable to addOrUpdateMenuItem: Invalid menu handle. [error=Unable to addOrUpdateMenuItem: %v error_location=github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908) error_op= error_text=Unable to addOrUpdateMenuItem: Invalid menu handle. error_type=errors.Error]
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.(*MenuItem).update (systray.go:194)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.AddMenuItem (systray.go:116)
ERROR systray: systray_windows.go:908   at main.onReady (main.go:39)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.Register.func2 (systray.go:91)
ERROR systray: systray_windows.go:908   at runtime.goexit (asm_amd64.s:1374)
ERROR systray: systray_windows.go:908 Caused by: Invalid menu handle.
ERROR systray: systray_windows.go:908 Unable to addOrUpdateMenuItem: Invalid menu handle. [error=Unable to addOrUpdateMenuItem: %v error_location=github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908) error_op= error_text=Unable to addOrUpdateMenuItem: Invalid menu handle. error_type=errors.Error]
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.(*MenuItem).update (systray.go:194)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.AddMenuItem (systray.go:116)
ERROR systray: systray_windows.go:908   at main.onReady (main.go:40)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.Register.func2 (systray.go:91)
ERROR systray: systray_windows.go:908   at runtime.goexit (asm_amd64.s:1374)
ERROR systray: systray_windows.go:908 Caused by: Invalid menu handle.
ERROR systray: systray_windows.go:908 Unable to addOrUpdateMenuItem: Invalid menu handle. [error=Unable to addOrUpdateMenuItem: %v error_location=github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908) error_op= error_text=Unable to addOrUpdateMenuItem: Invalid menu handle. error_type=errors.Error]
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.(*MenuItem).update (systray.go:194)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.(*MenuItem).AddSubMenuItem (systray.go:129)
ERROR systray: systray_windows.go:908   at main.onReady (main.go:41)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.Register.func2 (systray.go:91)
ERROR systray: systray_windows.go:908   at runtime.goexit (asm_amd64.s:1374)
ERROR systray: systray_windows.go:908 Caused by: Invalid menu handle.
ERROR systray: systray_windows.go:908 Unable to addOrUpdateMenuItem: Invalid menu handle. [error=Unable to addOrUpdateMenuItem: %v error_location=github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908) error_op= error_text=Unable to addOrUpdateMenuItem: Invalid menu handle. error_type=errors.Error]
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.(*MenuItem).update (systray.go:194)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.(*MenuItem).AddSubMenuItem (systray.go:129)
ERROR systray: systray_windows.go:908   at main.onReady (main.go:42)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.Register.func2 (systray.go:91)
ERROR systray: systray_windows.go:908   at runtime.goexit (asm_amd64.s:1374)
ERROR systray: systray_windows.go:908 Caused by: Invalid menu handle.
ERROR systray: systray_windows.go:908 Unable to addOrUpdateMenuItem: Invalid menu handle. [error=Unable to addOrUpdateMenuItem: %v error_location=github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908) error_op= error_text=Unable to addOrUpdateMenuItem: Invalid menu handle. error_type=errors.Error]
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.(*MenuItem).update (systray.go:194)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.(*MenuItem).AddSubMenuItem (systray.go:129)
ERROR systray: systray_windows.go:908   at main.onReady (main.go:43)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.Register.func2 (systray.go:91)
ERROR systray: systray_windows.go:908   at runtime.goexit (asm_amd64.s:1374)
ERROR systray: systray_windows.go:908 Caused by: Invalid menu handle.
ERROR systray: systray_windows.go:908 Unable to addOrUpdateMenuItem: Invalid menu handle. [error=Unable to addOrUpdateMenuItem: %v error_location=github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908) error_op= error_text=Unable to addOrUpdateMenuItem: Invalid menu handle. error_type=errors.Error]
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.(*MenuItem).update (systray.go:194)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.(*MenuItem).Disable (systray.go:159)
ERROR systray: systray_windows.go:908   at github.com/jsxxzy/inettray/core/tray.(*Tray).InitDisableMenu (tray.go:197)
ERROR systray: systray_windows.go:908   at github.com/jsxxzy/inettray/core/tray.(*Tray).Init (tray.go:205)
ERROR systray: systray_windows.go:908   at main.onReady (main.go:64)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.Register.func2 (systray.go:91)
ERROR systray: systray_windows.go:908   at runtime.goexit (asm_amd64.s:1374)
ERROR systray: systray_windows.go:908 Caused by: Invalid menu handle.
ERROR systray: systray_windows.go:908 Unable to addOrUpdateMenuItem: Invalid menu handle. [error=Unable to addOrUpdateMenuItem: %v error_location=github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908) error_op= error_text=Unable to addOrUpdateMenuItem: Invalid menu handle. error_type=errors.Error]
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.(*MenuItem).update (systray.go:194)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.(*MenuItem).Disable (systray.go:159)
ERROR systray: systray_windows.go:908   at github.com/jsxxzy/inettray/core/tray.(*Tray).InitDisableMenu (tray.go:198)
ERROR systray: systray_windows.go:908   at github.com/jsxxzy/inettray/core/tray.(*Tray).Init (tray.go:205)
ERROR systray: systray_windows.go:908   at main.onReady (main.go:64)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.Register.func2 (systray.go:91)
ERROR systray: systray_windows.go:908   at runtime.goexit (asm_amd64.s:1374)
ERROR systray: systray_windows.go:908 Caused by: Invalid menu handle.
ERROR systray: systray_windows.go:908 Unable to addOrUpdateMenuItem: Invalid menu handle. [error=Unable to addOrUpdateMenuItem: %v error_location=github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908) error_op= error_text=Unable to addOrUpdateMenuItem: Invalid menu handle. error_type=errors.Error]
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.(*MenuItem).update (systray.go:194)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.(*MenuItem).Disable (systray.go:159)
ERROR systray: systray_windows.go:908   at github.com/jsxxzy/inettray/core/tray.(*Tray).InitDisableMenu (tray.go:199)
ERROR systray: systray_windows.go:908   at github.com/jsxxzy/inettray/core/tray.(*Tray).Init (tray.go:205)
ERROR systray: systray_windows.go:908   at main.onReady (main.go:64)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.Register.func2 (systray.go:91)
ERROR systray: systray_windows.go:908   at runtime.goexit (asm_amd64.s:1374)
ERROR systray: systray_windows.go:908 Caused by: Invalid menu handle.
ERROR systray: systray_windows.go:908 Unable to addOrUpdateMenuItem: Invalid menu handle. [error=Unable to addOrUpdateMenuItem: %v error_location=github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908) error_op= error_text=Unable to addOrUpdateMenuItem: Invalid menu handle. error_type=errors.Error]
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.(*MenuItem).update (systray.go:194)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.(*MenuItem).Disable (systray.go:159)
ERROR systray: systray_windows.go:908   at github.com/jsxxzy/inettray/core/tray.(*Tray).InitDisableMenu (tray.go:200)
ERROR systray: systray_windows.go:908   at github.com/jsxxzy/inettray/core/tray.(*Tray).Init (tray.go:205)
ERROR systray: systray_windows.go:908   at main.onReady (main.go:64)
ERROR systray: systray_windows.go:908   at github.com/getlantern/systray.Register.func2 (systray.go:91)
ERROR systray: systray_windows.go:908   at runtime.goexit (asm_amd64.s:1374)
ERROR systray: systray_windows.go:908 Caused by: Invalid menu handle.

What happened?

Thank you

the project link:

https://github.com/jsxxzy/inettray

@shairozan
Copy link

I ran into this yesterday on an app that was working fine for MacOS, but wouldn't work on Windows. I found this article that indicated it seems to break if you try to do anything to the menu item before the icon is set.

For me, it was originally:

clientsMenuItem := systray.AddMenuItem("Clients", "Clients for which app is responsible")
systray.SetIcon(assets.Checkicon)
systray.SetTitle("appname")
systray.SetTooltip("app desc")

and it would give the same error you're seeing. I rearranged it to:

systray.SetIcon(assets.Checkicon)
systray.SetTitle("appname")
systray.SetTooltip("app desc")
clientsMenuItem := systray.AddMenuItem("Clients", "Clients for which app is responsible")

and it worked. Kind of strange, but there's something expected on the menu item set from those functions that's not immediately available or surfaced as an error shy of that obscure one you have in your logs.

@henri9813
Copy link

Hello,

The article you mentioned is offline.

Here is my main.go: https://github.com/henri9813/iPingTray/blob/main/main.go

Do you know why it crashed based on my implementation ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants