mirror of
https://github.com/netbirdio/gomobile-tvos-fork.git
synced 2026-05-22 18:43:29 -07:00
app: allow app.Main to return on Windows
Fixes golang/go#49499 Change-Id: Ia65b61b9e0707321439ea85d06bac5ed507b58c7 Reviewed-on: https://go-review.googlesource.com/c/mobile/+/369196 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com> Trust: Hyang-Ah Hana Kim <hyangah@gmail.com> Trust: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Changkun Ou <mail@changkun.de> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
+5
-1
@@ -287,8 +287,12 @@ func mainUI(vm, jniEnv, ctx uintptr) error {
|
||||
|
||||
donec := make(chan struct{})
|
||||
go func() {
|
||||
// close the donec channel in a defer statement
|
||||
// so that we could still be able to return even
|
||||
// if mainUserFn panics.
|
||||
defer close(donec)
|
||||
|
||||
mainUserFn(theApp)
|
||||
close(donec)
|
||||
}()
|
||||
|
||||
var pixelsPerPt float32
|
||||
|
||||
+15
-2
@@ -38,10 +38,23 @@ func main(f func(a App)) {
|
||||
}
|
||||
}()
|
||||
|
||||
go f(theApp)
|
||||
donec := make(chan struct{})
|
||||
go func() {
|
||||
// close the donec channel in a defer statement
|
||||
// so that we could still be able to return even
|
||||
// if f panics.
|
||||
defer close(donec)
|
||||
|
||||
f(theApp)
|
||||
}()
|
||||
|
||||
for {
|
||||
theApp.Send(convertEvent(w.NextEvent()))
|
||||
select {
|
||||
case <-donec:
|
||||
return
|
||||
default:
|
||||
theApp.Send(convertEvent(w.NextEvent()))
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
+5
-1
@@ -52,8 +52,12 @@ func main(f func(App)) {
|
||||
|
||||
donec := make(chan struct{})
|
||||
go func() {
|
||||
// close the donec channel in a defer statement
|
||||
// so that we could still be able to return even
|
||||
// if f panics.
|
||||
defer close(donec)
|
||||
|
||||
f(theApp)
|
||||
close(donec)
|
||||
}()
|
||||
|
||||
// TODO: can we get the actual vsync signal?
|
||||
|
||||
Reference in New Issue
Block a user