app: [macOS] panic if Main is not called from the main goroutine

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2024-06-02 09:07:29 +02:00
parent 46cc311d19
commit 175e134478
2 changed files with 8 additions and 1 deletions
+5 -1
View File
@@ -75,9 +75,13 @@ var displayLinks sync.Map
var mainFuncs = make(chan func(), 1)
func isMainThread() bool {
return bool(C.isMainThread())
}
// runOnMain runs the function on the main thread.
func runOnMain(f func()) {
if C.isMainThread() {
if isMainThread() {
f()
return
}
+3
View File
@@ -976,6 +976,9 @@ func (w *window) init() error {
}
func osMain() {
if !isMainThread() {
panic("app.Main must run on the main goroutine")
}
C.gio_main()
}