andlabs / ui

Platform-native GUI library for Go.
Other
8.33k stars 652 forks source link

Open file dialog crashes #412

Open doamatto opened 3 years ago

doamatto commented 3 years ago

When I try to use the ui.OpenFile() function, the application crashes with the following error in the console (scroll down to «Console log»)

Code:

pickFile := ui.NewButton("Pick video file")
box := ui.NewVerticalBox()
box.Append(pickFile, false)
window := ui.NewWindow("Demo", 300, 200, false)
window.SetMargined(true)
window.SetChild(box)
[...]
pickFile.OnClicked(func(*ui.Button) {
  filename := ui.OpenFile(mainwin)
  if filename == "" {
    filename = "(cancelled)"
  }
  file.SetText(filename)
})

Console log:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x51ed72]

goroutine 1 [running, locked to thread]:
github.com/andlabs/ui.OpenFile.func1(0x0, 0xc000176f90)
        /home/doamatto/go/pkg/mod/github.com/andlabs/ui@v0.0.0-20200610043537-70a69d6ae31e/stddialogs.go:18 +0x22
github.com/andlabs/ui.OpenFile(0x0, 0x0, 0x0)
        /home/doamatto/go/pkg/mod/github.com/andlabs/ui@v0.0.0-20200610043537-70a69d6ae31e/stddialogs.go:18 +0x44
main.main.func1.2(0xc000176d80)
        /home/doamatto/[...]/main.go:100 +0x36
github.com/andlabs/ui.pkguiDoButtonOnClicked(0x2703010, 0x0)
        /home/doamatto/go/pkg/mod/github.com/andlabs/ui@v0.0.0-20200610043537-70a69d6ae31e/button.go:60 +0x7b
github.com/andlabs/ui._cgoexpwrap_e99bb8362bf9_pkguiDoButtonOnClicked(0x2703010, 0x0)
        _cgo_gotypes.go:3863 +0x35
github.com/andlabs/ui._Cfunc_uiMain()
        _cgo_gotypes.go:2519 +0x41
github.com/andlabs/ui.Main(0xaeb3e8, 0x0, 0xc0000340b8)
        /home/doamatto/go/pkg/mod/github.com/andlabs/ui@v0.0.0-20200610043537-70a69d6ae31e/main.go:41 +0xff
main.main()
        /home/doamatto/[...]/main.go:13 +0x2d

Hardware info: Linux hackermans-mac-pro 5.8.0-7642-generic #47~1614007149~20.10~82fb226-Ubuntu SMP Tue Feb 23 02:59:01 UTC x86_64 x86_64 x86_64 GNU/Linux

Go version 1.14.7 linux/amd64

rubyFeedback commented 2 years ago

Have you tried this on libui-ng yet? Perhaps cody can help if it turns out to be a bug in libui itself.