app/internal/wm: [macOS] avoid deadlock in Window.Close

Native window callbacks now run in the same context as the event loop.
However, a call to Close immediately calls onClose which in turn wants
to send events. Break the deadlock by deferring the Close call.

Fixes gio#227

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2021-05-19 17:19:00 +02:00
parent 9ad492e93b
commit df0e058ea6
+7 -1
View File
@@ -206,7 +206,13 @@ func (w *window) runOnMain(f func()) {
}
func (w *window) Close() {
C.gio_close(w.window)
// gio_close immediately calls gio_onClose which sends events
// causing a deadlock because Close is called during an event.
// Break the deadlock by deferring the close, making Close more
// akin to a message like the other platforms.
go runOnMain(func() {
C.gio_close(w.window)
})
}
func (w *window) setStage(stage system.Stage) {