From 5c033ce4316ec58177658abbef46ecdedbec8047 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 4 Mar 2025 04:06:49 -0600 Subject: [PATCH] lock for gocui --- init.go | 2 ++ structs.go | 3 +++ 2 files changed, 5 insertions(+) diff --git a/init.go b/init.go index da00c80..6bb8efd 100644 --- a/init.go +++ b/init.go @@ -38,7 +38,9 @@ func (me *TreeInfo) catchActionChannel() { muAction.Lock() me.WaitOK() // time.Sleep(10 * time.Millisecond) + me.Lock() me.doAction(a) + me.Unlock() muAction.Unlock() } } diff --git a/structs.go b/structs.go index 53c058a..8e3bc19 100644 --- a/structs.go +++ b/structs.go @@ -7,6 +7,8 @@ package tree */ import ( + "sync" + "go.wit.com/lib/protobuf/guipb" "go.wit.com/widget" ) @@ -18,6 +20,7 @@ import ( var treeRoot *Node type TreeInfo struct { + sync.Mutex // a lock around the tree to serialize access ok bool // indicates the plugin actually initialized PluginName string // used to identify the plugin config *ToolkitConfigs // protobuf of plugin settings