From 113ae75a5074224fb35093cd3ea85b6281b18aa1 Mon Sep 17 00:00:00 2001 From: Rafael Chicoli Date: Tue, 13 Jul 2021 22:18:06 +0200 Subject: [PATCH 1/2] Format main.go file --- main.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index 356e0e87..dcd15fd5 100644 --- a/main.go +++ b/main.go @@ -3,8 +3,8 @@ package ui import ( - "runtime" "errors" + "runtime" "sync" "unsafe" ) @@ -52,9 +52,9 @@ func Quit() { // These prevent the passing of Go functions into C land. // TODO make an actual sparse list instead of this monotonic map thingy var ( - qmmap = make(map[uintptr]func()) + qmmap = make(map[uintptr]func()) qmcurrent = uintptr(0) - qmlock sync.Mutex + qmlock sync.Mutex ) // QueueMain queues f to be executed on the GUI thread when @@ -64,11 +64,11 @@ var ( // primary purpose is to allow communication between other // goroutines and the GUI thread. Calling QueueMain after Quit // has been called results in undefined behavior. -// +// // If you start a goroutine in f, it also cannot call package ui // functions. So for instance, the following will result in // undefined behavior: -// +// // ui.QueueMain(func() { // go ui.MsgBox(...) // }) From 9b1890e48ad34414514c722f3b33e5ab2202345e Mon Sep 17 00:00:00 2001 From: Rafael Chicoli Date: Tue, 13 Jul 2021 22:29:23 +0200 Subject: [PATCH 2/2] Added Uninit func to export C.uiUninit calls --- main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.go b/main.go index dcd15fd5..0c7b75c0 100644 --- a/main.go +++ b/main.go @@ -42,6 +42,11 @@ func Main(f func()) error { return nil } +// Uninit calls C.uiUninit to uninitialize all allocated objects +func Uninit() { + C.uiUninit() +} + // Quit queues a return from Main. It does not exit the program. // It also does not immediately cause Main to return; Main will // return when it next can. Quit must be called from the GUI thread.