app/internal/wm: [macOS] avoid crash in window.Wakeup

window.Wakeup assumes the window.w field is never reset to nil. Avoid
doing that in gio_onClose.

While here, ensure a valid window handle in window.Close by calling
the checked window.runOnMain method, not the bare runOnMain function.

Fixes gio#258

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2021-08-27 06:01:21 +02:00
parent b9ede6d735
commit baa98e7737
+4 -2
View File
@@ -287,7 +287,7 @@ func (w *window) Close() {
// 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() {
go w.runOnMain(func() {
C.closeWindow(w.window)
})
}
@@ -425,7 +425,9 @@ func gio_onClose(view C.CFTypeRef) {
w.displayLink.Close()
C.CFRelease(w.view)
C.CFRelease(w.window)
*w = window{}
w.view = 0
w.window = 0
w.displayLink = nil
}
//export gio_onHide