andlabs / andlabs/ui

OpenFile crashes on OSX

Open
#107 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
8.4k
Forks
639
PR merge metrics
No merged PRs in 30d

Description

The following is a small program to capture a filename using ui.OpenFile:

``` go
package main

import (
"github.com/andlabs/ui"
)

var window ui.Window
var srcName string

func loadFile(filename string) {
srcName = filename
}

func initUI() {
b := ui.NewButton("Read")
b.OnClicked(func() {
ui.OpenFile (window, loadFile)
})
window = ui.NewWindow("Window", 200, 200, b)
window.OnClosing(func() bool {
ui.Stop()
return true
})
window.Show()
}

func main() {
go ui.Do(initUI)
err := ui.Go()
if err != nil {
panic(err)
}
}
```

When I run it on OSX, it crashes with the following stack trace (I don't have an available Windows or Unix box to check those):

```
$ sippui
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x2d pc=0x4041f43]

goroutine 1 [running, locked to thread]:
github.com/andlabs/ui.finishOpenFile(0x4358b30, 0xc20801d5a0)
/Users/Raul/gocode/src/github.com/andlabs/ui/dialog_darwin.go:24 +0xa3
github.com/andlabs/ui._Cfunc_uimsgloop()
/Users/Raul/gocode/src/github.com/andlabs/ui/:442 +0x45
github.com/andlabs/ui.uimsgloop()
/Users/Raul/gocode/src/github.com/andlabs/ui/uitask_darwin.go:27 +0x1b
github.com/andlabs/ui.Go(0x0, 0x0)
/Users/Raul/gocode/src/github.com/andlabs/ui/uitask.go:22 +0x74
main.main()
/Users/Raul/gocode/src/github.com/Causticity/sipp/sippui/main.go:29 +0x3b

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:2232 +0x1

goroutine 6 [chan receive]:
github.com/andlabs/ui.uiissueloop()
/Users/Raul/gocode/src/github.com/andlabs/ui/uitask.go:59 +0x53
created by github.com/andlabs/ui.Go
/Users/Raul/gocode/src/github.com/andlabs/ui/uitask.go:21 +0x6d
$
```

To me it looks like OpenFile has a bug causing it to crash on invocation of the callback, but perhaps I'm missing something.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.