Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose C.uiUninit() function #417

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 10 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
package ui

import (
"runtime"
"errors"
"runtime"
"sync"
"unsafe"
)
Expand Down Expand Up @@ -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.
Expand All @@ -52,9 +57,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
Expand All @@ -64,11 +69,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(...)
// })
Expand Down