mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-03 16:35:36 +00:00
app: delay Window.Close until after event processing
The fix for #340, b2a99fddca, 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 <mail@eliasnaur.com>
This commit is contained in:
+6
-1
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user