From 650263a314906bdbf032326101a8df27af19978b Mon Sep 17 00:00:00 2001 From: faiface Date: Mon, 1 May 2017 12:18:23 +0200 Subject: [PATCH] fix creating window with no icon --- pixelgl/window.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/pixelgl/window.go b/pixelgl/window.go index df8be4f..36a8da3 100644 --- a/pixelgl/window.go +++ b/pixelgl/window.go @@ -122,6 +122,17 @@ func NewWindow(cfg WindowConfig) (*Window, error) { return nil, errors.Wrap(err, "creating window failed") } + if len(cfg.Icon) > 0 { + imgs := make([]image.Image, len(cfg.Icon)) + for i, icon := range cfg.Icon { + pic := pixel.PictureDataFromPicture(icon) + imgs[i] = pic.Image() + } + mainthread.Call(func() { + w.window.SetIcon(imgs) + }) + } + w.SetVSync(cfg.VSync) w.initInput() @@ -131,14 +142,7 @@ func NewWindow(cfg WindowConfig) (*Window, error) { w.Update() runtime.SetFinalizer(w, (*Window).Destroy) - imgs := make([]image.Image, len(cfg.Icon)) - for i, v := range cfg.Icon { - pic := pixel.PictureDataFromPicture(v) - imgs[i] = pic.Image() - } - mainthread.Call(func() { - w.window.SetIcon(imgs) - }) + return w, nil }