app: release GPU before processing DestroyEvent

In fact, move the release of the GPU to a deferred function, saving
a release.

Fixes #65

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-11-09 18:13:14 +01:00
parent b950aa71e1
commit 8620b43eb3
+6 -2
View File
@@ -218,6 +218,12 @@ func (w *Window) run(opts *window.Options) {
w.out <- system.DestroyEvent{Err: err}
return
}
defer func() {
if w.gpu != nil {
w.gpu.Release()
w.gpu = nil
}
}()
for {
var timer <-chan time.Time
if w.delayedDraw != nil {
@@ -297,8 +303,6 @@ func (w *Window) run(opts *window.Options) {
}
if e2.Sync {
if err := w.gpu.Flush(); err != nil {
w.gpu.Release()
w.gpu = nil
w.destroy(err)
return
}