From 8c05dc65787fde7d08040aea857065d6cfb35c91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B6=E3=83=BC=E3=81=A8=20/=20Yoshiaki=20Ueda?= Date: Sun, 12 Jul 2020 21:09:11 +0900 Subject: [PATCH] fix condition conflict --- cli/main.go | 2 +- vrc_auto_rejoin_tool.go | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/cli/main.go b/cli/main.go index 811753f..fd297f1 100644 --- a/cli/main.go +++ b/cli/main.go @@ -68,7 +68,7 @@ func welcomeScreen(a fyne.App, v vrcarjt.AutoRejoin, w fyne.Window) fyne.CanvasO widget.NewGroup("Controls", fyne.NewContainerWithLayout(layout.NewGridLayout(2), - widget.NewButton("Status: Start", func() { + widget.NewButton("Start", func() { if v.IsRun() { return } diff --git a/vrc_auto_rejoin_tool.go b/vrc_auto_rejoin_tool.go index 5e0c377..0039483 100644 --- a/vrc_auto_rejoin_tool.go +++ b/vrc_auto_rejoin_tool.go @@ -128,17 +128,19 @@ func (v *VRCAutoRejoinTool) Run() error { ok, err := lock.Try() if err != nil || !ok { + v.lock.Lock() + v.running = false + v.lock.Unlock() return ErrDuplicateRun } if err = lock.Lock(); err != nil { + v.lock.Lock() + v.running = false + v.lock.Unlock() return err } - v.lock.Lock() - v.running = true - v.lock.Unlock() - defer lock.UnLock() v.setupTimeLocation() @@ -157,6 +159,10 @@ func (v *VRCAutoRejoinTool) Run() error { return err } + v.lock.Lock() + v.running = true + v.lock.Unlock() + v.playAudioFile("start.wav") v.wait.Add(1)