From 40c082e94961adaf55886b45710a54d0247ff1bf Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Fri, 18 Dec 2020 10:18:21 +0100 Subject: [PATCH] app/internal/window: use defer for cleanup function Avoids a vet warning about unreachable code: currently, the cleanup function is never reached. Signed-off-by: Elias Naur --- app/internal/window/os_js.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/internal/window/os_js.go b/app/internal/window/os_js.go index 66ab3bf8..c2feb141 100644 --- a/app/internal/window/os_js.go +++ b/app/internal/window/os_js.go @@ -69,12 +69,12 @@ func NewWindow(win Callbacks, opts *Options) error { w.addHistory() w.w = win go func() { + defer w.cleanup() w.w.SetDriver(w) w.blur() w.w.Event(system.StageEvent{Stage: system.StageRunning}) w.draw(true) select {} - w.cleanup() }() return nil } @@ -398,7 +398,7 @@ func (w *window) addEventListener(this js.Value, event string, f func(this js.Va } // funcOf is like js.FuncOf but adds the js.Func to a list of -// functions to be released up. +// functions to be released during cleanup. func (w *window) funcOf(f func(this js.Value, args []js.Value) interface{}) js.Func { jsf := js.FuncOf(f) w.cleanfuncs = append(w.cleanfuncs, jsf.Release)