From be5458c0a37cf83f2392f3951233dd3f9f406c14 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sat, 1 Mar 2014 15:18:29 -0500 Subject: 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. --- init.go | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'init.go') 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) } -- cgit v1.2.3