From 453c2c4589f28ab3a1b7cd9882638f9c61a9ac21 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Fri, 2 Sep 2016 01:07:41 +0900 Subject: [PATCH] ui: Remove Terminate --- internal/loop/run.go | 4 ---- internal/ui/ui.go | 1 - internal/ui/ui_glfw.go | 14 ++++++-------- internal/ui/ui_js.go | 5 ----- internal/ui/ui_mobile.go | 4 ---- 5 files changed, 6 insertions(+), 22 deletions(-) diff --git a/internal/loop/run.go b/internal/loop/run.go index da43d3d24..f92b1f8c7 100644 --- a/internal/loop/run.go +++ b/internal/loop/run.go @@ -112,10 +112,6 @@ func Run(g GraphicsContext, width, height int, scale float64, title string, fps if err := ui.CurrentUI().Start(width, height, scale, title); err != nil { return err } - // TODO: Use the error value - defer func() { - _ = ui.CurrentUI().Terminate() - }() n := now() currentRunContext.lastUpdated = n diff --git a/internal/ui/ui.go b/internal/ui/ui.go index 56683ee24..cbbc64989 100644 --- a/internal/ui/ui.go +++ b/internal/ui/ui.go @@ -21,7 +21,6 @@ type GraphicsContext interface { type UserInterface interface { Start(width, height int, scale float64, title string) error - Terminate() error AnimationFrameLoop(g GraphicsContext) error ScreenScale() float64 SetScreenSize(width, height int) (bool, error) diff --git a/internal/ui/ui_glfw.go b/internal/ui/ui_glfw.go index a815ddb44..96033fdb6 100644 --- a/internal/ui/ui_glfw.go +++ b/internal/ui/ui_glfw.go @@ -241,15 +241,13 @@ func (u *userInterface) update(g GraphicsContext) error { return nil } -func (u *userInterface) Terminate() error { - _ = u.runOnMainThread(func() error { - glfw.Terminate() - return nil - }) - return nil -} - func (u *userInterface) AnimationFrameLoop(g GraphicsContext) error { + defer func() { + _ = u.runOnMainThread(func() error { + glfw.Terminate() + return nil + }) + }() for { if err := u.update(g); err != nil { return err diff --git a/internal/ui/ui_js.go b/internal/ui/ui_js.go index 9b23ec7fb..bb2fa42f9 100644 --- a/internal/ui/ui_js.go +++ b/internal/ui/ui_js.go @@ -87,11 +87,6 @@ func (u *userInterface) update(g GraphicsContext) error { return nil } -func (u *userInterface) Terminate() error { - // Do nothing. - return nil -} - func (u *userInterface) AnimationFrameLoop(g GraphicsContext) error { ch := make(chan error) var f func() diff --git a/internal/ui/ui_mobile.go b/internal/ui/ui_mobile.go index c169f76d0..3db378d1e 100644 --- a/internal/ui/ui_mobile.go +++ b/internal/ui/ui_mobile.go @@ -77,10 +77,6 @@ func (u *userInterface) Start(width, height int, scale float64, title string) er return nil } -func (u *userInterface) Terminate() error { - return nil -} - func (u *userInterface) AnimationFrameLoop(g GraphicsContext) error { for { if u.sizeChanged {