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