summaryrefslogtreecommitdiff
path: root/init.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-03-01 15:18:29 -0500
committerPietro Gagliardi <[email protected]>2014-03-01 15:18:29 -0500
commitbe5458c0a37cf83f2392f3951233dd3f9f406c14 (patch)
treeae358af220f4533465ca8807157889b819dcf884 /init.go
parentc8c257f8c84c163354a2b3ba7c97bd76f2700443 (diff)
Major code restructure to allow Cocoa to work correctly. Cocoa requires that the application loop run on the very first OS thread created, not just an any ordinary thread. To support this, your code must now be run by the UI init code. Windows and Unix builds still work fine; Mac OS X fails for reasons I now have to debug.
Diffstat (limited to 'init.go')
-rw-r--r--init.go23
1 files changed, 7 insertions, 16 deletions
diff --git a/init.go b/init.go
index 1f6d542..a47266c 100644
--- a/init.go
+++ b/init.go
@@ -1,20 +1,11 @@
// 11 february 2014
package ui
-import (
- "os"
-)
-
-func init() {
- initDone := make(chan error)
- go ui(initDone)
- err := <-initDone
- if err != nil {
- // TODO provide copying instructions? will need to be system-specific
- MsgBoxError("UI Library Init Failure",
- "A failure occured during UI library initialization:\n%v\n" +
- "Please report this to the application developer or on http://github.com/andlabs/ui.",
- err)
- os.Exit(1)
- }
+// Go sets up the UI environment and runs main in a goroutine.
+// If initialization fails, Go returns an error.
+// Otherwise, Go does not return to its caller until (unless? TODO) the application loop exits, at which point it returns nil.
+//
+// This model is undesirable, but Cocoa limitations require it.
+func Go(main func()) error {
+ return ui(main)
}