summaryrefslogtreecommitdiff
path: root/init.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-06-28 16:37:55 -0400
committerPietro Gagliardi <[email protected]>2014-06-28 16:37:55 -0400
commitaffc65a5a402534527c4d4fbc5b381b5b1283445 (patch)
treeef34e20694a809577b2d609d9e3ffadfe64bbc12 /init.go
parent02d6a03ba3a657aa7b50d072771361236bb207a3 (diff)
Fixed the build. New API works on Windows! Also removed TODO on dialogs in Windows since I can't reproduce the weird behavior anymore; I guess the new code fixes it.
Diffstat (limited to 'init.go')
-rw-r--r--init.go15
1 files changed, 12 insertions, 3 deletions
diff --git a/init.go b/init.go
index a6a4882..72f24ef 100644
--- a/init.go
+++ b/init.go
@@ -18,7 +18,7 @@ import (
// If you must, and if the toolkit also has environment variable equivalents to these flags (for instance, GTK+), use those instead.
func Go() error {
runtime.LockOSThread()
- if err := uiinit(main); err != nil {
+ if err := uiinit(); err != nil {
return err
}
Ready <- struct{}{}
@@ -37,9 +37,18 @@ var Ready = make(chan struct{})
var Stop = make(chan struct{})
// This function is a simple helper functionn that basically pushes the effect of a function call for later. This allows the selected safe Window methods to be safe.
-// It's also currently used by the various dialog box functions on Windows to allow them to return instantly, rather than wait for the dialog box to finish (which both GTK+ and Mac OS X let you do). I consider this a race condition bug. TODO (also TODO document the /intended/ behavior)
+// TODO make sure this acts sanely if called from uitask itself
func touitask(f func()) {
+ done := make(chan struct{})
+ defer close(done)
go func() { // to avoid locking uitask itself
- uitask <- f
+ done2 := make(chan struct{}) // make the chain uitask <- f <- uitask to avoid deadlocks
+ defer close(done2)
+ uitask <- func() {
+ f()
+ done2 <- struct{}{}
+ }
+ done <- <-done2
}()
+ <-done
}