From e19f38bd4f72ce286bf1c7259851db4693d10568 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 29 Aug 2020 03:02:20 +0900 Subject: [PATCH] uidriver/mobile: Refactoring --- internal/uidriver/mobile/ui.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/uidriver/mobile/ui.go b/internal/uidriver/mobile/ui.go index 4ef9b9b09..1b90f922f 100644 --- a/internal/uidriver/mobile/ui.go +++ b/internal/uidriver/mobile/ui.go @@ -287,9 +287,10 @@ func (u *UserInterface) run(context driver.UIContext, mainloop bool) (err error) u.m.Lock() u.sizeChanged = true - u.context = context u.m.Unlock() + u.context = context + if u.Graphics().IsGL() { var ctx gl.Context if mainloop { @@ -321,7 +322,7 @@ func (u *UserInterface) run(context driver.UIContext, mainloop bool) (err error) func (u *UserInterface) layoutIfNeeded() { var outsideWidth, outsideHeight float64 - u.m.Lock() + u.m.RLock() sizeChanged := u.sizeChanged if sizeChanged { if u.gbuildWidthPx == 0 || u.gbuildHeightPx == 0 { @@ -335,7 +336,7 @@ func (u *UserInterface) layoutIfNeeded() { } } u.sizeChanged = false - u.m.Unlock() + u.m.RUnlock() if sizeChanged { u.context.Layout(outsideWidth, outsideHeight)