From 1d0a7b845ed6cc7a0d29445d16fe5a268e7b6ab1 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Tue, 12 Nov 2019 22:17:29 +0100 Subject: [PATCH] app: destroy GPU before ack'ing the DestroyEvent The DestroyEvent ack allows the backend to release the window. Ensure that the GPU associated with the window is done before that happens. Updates gio#67 Signed-off-by: Elias Naur --- app/window.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/window.go b/app/window.go index 4127baac..8b41d215 100644 --- a/app/window.go +++ b/app/window.go @@ -200,6 +200,7 @@ func (w *Window) waitAck() { // Prematurely destroy the window and wait for the native window // destroy event. func (w *Window) destroy(err error) { + w.destroyGPU() // Ack the current event. w.ack <- struct{}{} w.out <- system.DestroyEvent{Err: err} @@ -211,6 +212,13 @@ func (w *Window) destroy(err error) { } } +func (w *Window) destroyGPU() { + if w.gpu != nil { + w.gpu.Release() + w.gpu = nil + } +} + func (w *Window) run(opts *window.Options) { defer close(w.in) defer close(w.out) @@ -309,6 +317,7 @@ func (w *Window) run(opts *window.Options) { case driverEvent: w.driver = e2.driver case system.DestroyEvent: + w.destroyGPU() w.out <- e2 w.ack <- struct{}{} return