From 56394ac50e81118265b78669eb7dfda1fc2d545e Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Wed, 27 Jan 2021 06:03:17 +1100 Subject: [PATCH] Use mutex when doing a Store resync --- v2/internal/runtime/store.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/v2/internal/runtime/store.go b/v2/internal/runtime/store.go index 78d2e85c..3ad30e7d 100644 --- a/v2/internal/runtime/store.go +++ b/v2/internal/runtime/store.go @@ -153,6 +153,9 @@ func (s *Store) setupListener() { func (s *Store) resync() { + // Lock + s.mux.Lock() + // Stringify data newdata, err := json.Marshal(s.data.Interface()) if err != nil { @@ -162,6 +165,9 @@ func (s *Store) resync() { } } + // Lock + s.mux.Unlock() + // Emit event to front end s.runtime.Events.Emit("wails:sync:store:updatedbybackend:"+s.name, string(newdata))