From f23a4f8452e3cd3264a008c680863105305ff1d7 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Sat, 29 Jan 2022 13:30:23 +0100 Subject: [PATCH] app: delay Window.Close until after event processing The fix for #340, b2a99fddcad3c952cc7e0dfb05021c57de072693, deferred all driver functions until after event processing. Deferring functions breaks Window.Run which expects to complete during event processing. This change is an alternative, more targeted fix, namely deferring just Window.Close until after event processing. A follow-up will revert the previous fix. References: https://todo.sr.ht/~eliasnaur/gio/340 Signed-off-by: Elias Naur --- app/window.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/window.go b/app/window.go index 56c0b1f6..608fcae1 100644 --- a/app/window.go +++ b/app/window.go @@ -54,6 +54,7 @@ type Window struct { out chan event.Event frames chan *op.Ops frameAck chan struct{} + closing bool // dead is closed when the window is destroyed. dead chan struct{} @@ -326,7 +327,7 @@ func (w *Window) SetCursorName(name pointer.CursorName) { // all others are stubbed. func (w *Window) Close() { w.driverDefer(func(d driver) { - d.Close() + w.closing = true }) } @@ -429,6 +430,10 @@ func (c *callbacks) Event(e event.Event) { } c.w.defers = c.w.defers[:0] c.w.updateState(c.d) + if c.w.closing { + c.w.closing = false + c.d.Close() + } } // SemanticRoot returns the ID of the semantic root.