Ah, fixed the stalling: logic error in the test program itself.

This commit is contained in:
Pietro Gagliardi 2014-07-19 10:16:00 -04:00
parent 627abfd593
commit 214dc6cd5c
1 changed files with 24 additions and 21 deletions

View File

@ -14,14 +14,15 @@ var closeOnClick = flag.Bool("close", false, "close on click")
// because Cocoa hates being run off the main thread, even if it's run exclusively off the main thread // because Cocoa hates being run off the main thread, even if it's run exclusively off the main thread
func init() { func init() {
flag.Parse() flag.Parse()
go Do(func() { go func() {
done := make(chan struct{})
Do(func() {
w := NewWindow("Hello", 320, 240) w := NewWindow("Hello", 320, 240)
b := NewButton("There") b := NewButton("There")
w.SetControl(b) w.SetControl(b)
if *closeOnClick { if *closeOnClick {
b.SetText("Click to Close") b.SetText("Click to Close")
} }
done := make(chan struct{})
w.OnClosing(func() bool { w.OnClosing(func() bool {
if *closeOnClick { if *closeOnClick {
panic("window closed normally in close on click mode (should not happen)") panic("window closed normally in close on click mode (should not happen)")
@ -31,6 +32,7 @@ func init() {
done <- struct{}{} done <- struct{}{}
return true return true
}) })
// GTK+ TODO: this is causing a resize event to happen afterward?!
b.OnClicked(func() { b.OnClicked(func() {
println("in OnClicked()") println("in OnClicked()")
if *closeOnClick { if *closeOnClick {
@ -40,8 +42,9 @@ func init() {
} }
}) })
w.Show() w.Show()
<-done
}) })
<-done
}()
err := Go() err := Go()
if err != nil { if err != nil {
panic(err) panic(err)