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 <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-11-12 22:17:29 +01:00
parent 41abb5b08d
commit 1d0a7b845e
+9
View File
@@ -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