fyne-io / systray

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

Panic when not setting TemplateIcon #22

Closed coezbek closed 1 year ago

coezbek commented 2 years ago

I am getting the following crash when cross-compiling from Linux to Windows and not setting the Template Icon:

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x7c0348]

goroutine 21 [running]:
fyne.io/systray.(*winTray).setTooltip(0xb61380, {0x945b8f, 0xc0000860b0})
        /home/coezbek/go/pkg/mod/fyne.io/systray@v1.10.0/systray_windows.go:260 +0xc8

My code (note the commented out SetTemplateIcon). Everything properly works when I set the TemplateIcon.


func onReady() {
    // systray.SetTemplateIcon(icon.Data, icon.Data)
    systray.SetTitle("Awesome App")
    systray.SetTooltip("Nephrolytix Sentinel")
    addQuitItem()
}

func main() {
    onExit := func() {
        fmt.Println("OnExit called")
    }

    systray.Run(onReady, onExit)
}
andydotxyz commented 2 years ago

What is the expected outcome of having a system tray item with no icon set?

coezbek commented 2 years ago

Lantern/systray just showed an empty/transparent icon. In any case it would be better to not crash or describe that the SetTemplateIcon must be called first.

andydotxyz commented 2 years ago

Can you please provide the full back trace. I cannot tell why it is failing from just the last entry

coezbek commented 2 years ago
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0xd50348]

goroutine 8 [running]:
fyne.io/systray.(*winTray).setTooltip(0x10f1380, {0xed5b8f, 0xc000106050})
        /home/coezbek/go/pkg/mod/fyne.io/systray@v1.10.0/systray_windows.go:260 +0xc8
fyne.io/systray.SetTooltip({0xed5b8f, 0x1})
        /home/coezbek/go/pkg/mod/fyne.io/systray@v1.10.0/systray_windows.go:961 +0x2b
main.onReady()
        /home/coezbek/2022/sentinel/sentinel.go:114 +0x25
fyne.io/systray.Register.func2()
        /home/coezbek/go/pkg/mod/fyne.io/systray@v1.10.0/systray.go:98 +0x32
created by fyne.io/systray.Register
        /home/coezbek/go/pkg/mod/fyne.io/systray@v1.10.0/systray.go:96 +0xc8
exit status 2

Hope this helps!

andydotxyz commented 1 year ago

I cannot replicate on other OS will have to get Windows booted

andydotxyz commented 1 year ago

Turns out it was fixed upstream. I cherry picked the commits that have happened since we forked and this issue seems to be resolved.