From f6e9f6861dc5605ce7510bc36ee227d4d6b13a57 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Tue, 6 Aug 2024 16:09:34 +0200 Subject: [PATCH] app: close the window before reporting a GPU error When a GPU error occurs forcing the reporting of a DestroyEvent is not appropriate, because the backend that controls the underlying window is not aware of the error and will continue to report events. Replace the crude DestroyEvent by stashing the error and asking the window nicely to close. The, report the stashed error in the otherwise regular DestroyEvent. Hopefully, this second attempt fixes #603. Fixes: https://todo.sr.ht/~eliasnaur/gio/603 Signed-off-by: Elias Naur --- app/window.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/window.go b/app/window.go index e1615b9a..8ddc21e6 100644 --- a/app/window.go +++ b/app/window.go @@ -89,6 +89,9 @@ type Window struct { } imeState editorState driver driver + // gpuErr tracks the GPU error that is to be reported when + // the window is closed. + gpuErr error // invMu protects mayInvalidate. invMu sync.Mutex @@ -227,7 +230,8 @@ func (w *Window) processFrame(frame *op.Ops, ack chan<- struct{}) { w.lastFrame.deco.Add(wrapper) if err := w.validateAndProcess(w.lastFrame.size, w.lastFrame.sync, wrapper, ack); err != nil { w.destroyGPU() - w.driver.ProcessEvent(DestroyEvent{Err: err}) + w.gpuErr = err + w.driver.Perform(system.ActionClose) return } w.updateState() @@ -637,6 +641,9 @@ func (w *Window) processEvent(e event.Event) bool { e2.Size = e2.Size.Sub(offset) w.coalesced.frame = &e2 case DestroyEvent: + if w.gpuErr != nil { + e2.Err = w.gpuErr + } w.destroyGPU() w.invMu.Lock() w.mayInvalidate = false