From baa98e7737774ba0c9f28abcb43a444f1d27d38b Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Fri, 27 Aug 2021 06:01:21 +0200 Subject: [PATCH] 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 --- app/internal/wm/os_macos.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/internal/wm/os_macos.go b/app/internal/wm/os_macos.go index 19aa9838..1ab07d81 100644 --- a/app/internal/wm/os_macos.go +++ b/app/internal/wm/os_macos.go @@ -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