fyne-io / systray

a cross platfrom Go library to place an icon and menu in the notification area
Apache License 2.0
223 stars 41 forks source link

Successive calls to `item.SetTitle` causes panic #79

Closed gabe565 closed 2 months ago

gabe565 commented 2 months ago

Hi!

I had a quick question about 03c78c0eeffdba02e75ddec29d7942770ca1e9b0. After updating, successive calls to item.SetTitle causes my application to panic on this line since the channel has already been closed:

panic: close of closed channel

goroutine 29 [running]:
fyne.io/systray.(*MenuItem).update(0x140000a6440)
    fyne.io/systray@v1.10.1-0.20240608091126-03c78c0eeffd/systray.go:273 +0x6c
fyne.io/systray.(*MenuItem).SetTitle(...)
    fyne.io/systray@v1.10.1-0.20240608091126-03c78c0eeffd/systray.go:199
github.com/gabe565/nightscout-menu-bar/internal/tray.(*Tray).onReady(0x140000c2000)
    github.com/gabe565/nightscout-menu-bar/internal/tray/systray.go:131 +0x354
fyne.io/systray.Register.func2()
    fyne.io/systray@v1.10.1-0.20240608091126-03c78c0eeffd/systray.go:112 +0x38
created by fyne.io/systray.Register in goroutine 1
    fyne.io/systray@v1.10.1-0.20240608091126-03c78c0eeffd/systray.go:110 +0xb8
exit status 2

My application updates the title every minute or so. Is item.SetTitle not intended to be used this way?

Thank you!

andydotxyz commented 2 months ago

SetTitle should be callable any number of times. It looks like the channel being closed is in subtly wrong scope.

andydotxyz commented 2 months ago

Should be fixed now, sorry for that

gabe565 commented 2 months ago

No problem. Thank you for the quick fix! Love all of the work you do