start looking into proper mutex locking

This commit is contained in:
Jeff Carr 2025-03-03 11:59:45 -06:00
parent 75014f4b28
commit 76e15fa1df
4 changed files with 41 additions and 30 deletions

38
help.go
View File

@ -72,10 +72,6 @@ func showHelp() error {
}
help.SelBgColor = gocui.ColorGreen
help.SelFgColor = gocui.ColorBlack
// fmt.Fprintln(help, "Enter: Click Button")
// fmt.Fprintln(help, "Tab/Space: Switch Buttons")
// fmt.Fprintln(help, "Backspace: Delete Button")
// fmt.Fprintln(help, "Arrow keys: Move Button")
fmt.Fprintln(help, strings.Join(helpText, "\n"))
@ -85,27 +81,19 @@ func showHelp() error {
}
g.SetViewOnTop("help")
me.helpLabel = help
if me.treeRoot == nil {
log.Info("gogui makeClock() error. treeRoot == nil")
return nil
} else {
if me.notify.clock.tk == nil {
makeClock(me.notify.clock.wId)
me.notify.clock.tk.MoveToOffset(maxX-me.notify.clock.offsetW, 1)
me.notify.clock.tk.Hide()
me.notify.clock.tk.Show()
/*
if me.treeRoot == nil {
log.Info("gogui makeClock() error. treeRoot == nil")
return nil
} else {
if me.stdout.tk == nil {
makeOutputWidget(me.baseGui, "made this in showHelp()")
msg := fmt.Sprintf("test to stdout from in showHelp() %d\n", me.ecount)
me.stdout.Write([]byte(msg))
log.Log(NOW, "log.log(NOW) test")
}
}
if me.notify.clock.tk != nil {
me.notify.clock.tk.MoveToOffset(maxX-me.notify.clock.offsetW, 1)
me.notify.clock.tk.Hide()
me.notify.clock.tk.Show()
}
if me.stdout.tk == nil {
makeOutputWidget(me.baseGui, "made this in showHelp()")
msg := fmt.Sprintf("test to stdout from in showHelp() %d\n", me.ecount)
me.stdout.Write([]byte(msg))
log.Log(NOW, "log.log(NOW) test")
}
}
*/
return nil
}

View File

@ -70,6 +70,13 @@ func toolkitInit() {
me.BG.tk = makeNewInternalWidget(me.BG.wId)
}
// SETUP libnotify
makeNotifyClock(me.notify.clock.wId)
if me.stdout.tk == nil {
makeOutputWidget(me.baseGui, "from setThingsOnTop()")
}
// PUT INIT DEBUG COOE HERE
var toggle bool
for i := 0; i < 6; i++ {
@ -77,7 +84,7 @@ func toolkitInit() {
w.dumpTree("MM")
w.dumpWindows("WW")
time.Sleep(1000 * time.Millisecond)
time.Sleep(300 * time.Millisecond)
if toggle {
toggle = false
log.Info("gocui toolkitInit() put testing true stuff here")

View File

@ -52,15 +52,14 @@ func makeNewInternalWidget(wId int) *guiWidget {
return tk
}
func makeClock(wId int) {
func makeNotifyClock(wId int) {
if me.treeRoot == nil {
log.Info("gogui makeClock() error. treeRoot == nil")
return
}
me.notify.clock.tk = makeNewInternalWidget(wId)
me.notify.clock.tk.dumpWidget("init() clock")
w, h := me.baseGui.MousePosition()
me.notify.clock.tk.MoveToOffset(w, h)
me.notify.clock.tk.MoveToOffset(0, 0)
me.notify.clock.tk.labelN = time.Now().Format("15:04:05")
me.notify.clock.tk.frame = false
me.notify.clock.tk.setColorLabel()
@ -151,7 +150,7 @@ func setBottomBG() {
return
}
tk := me.BG.tk
log.Info("found BG. setting to bottom", tk.cuiName)
// log.Info("found BG. setting to bottom", tk.cuiName)
if tk.v == nil {
w, h := me.baseGui.Size()
a := -1

View File

@ -162,12 +162,20 @@ func (tk *guiWidget) drawView() {
log.Log(ERROR, "drawView() internal plugin error err = nil")
return
}
if !errors.Is(err, gocui.ErrUnknownView) {
tk.dumpWidget("drawView() err")
log.Log(ERROR, "drawView() internal plugin error error.IS()", err)
return
}
if tk.v == nil {
log.Info("MUTEX FAIL. tk.v == nil here in drawView()")
log.Info("MUTEX FAIL. tk.v == nil here in drawView()")
log.Info("MUTEX FAIL. tk.v == nil here in drawView()")
return
}
// this actually sends the text to display to gocui
tk.v.Wrap = true
tk.v.Frame = tk.frame
@ -195,6 +203,14 @@ func (tk *guiWidget) drawView() {
}
default:
}
if tk.v == nil {
log.Info("MUTEX FAIL 2. tk.v was deleted somehow tk.v == nil here in drawView()")
log.Info("MUTEX FAIL 2. tk.v == nil here in drawView()")
log.Info("MUTEX FAIL 2. tk.v == nil here in drawView()")
return
}
// if you don't do this here, it will be black & white only
if tk.color != nil {
tk.v.FrameColor = tk.color.frame
@ -203,6 +219,7 @@ func (tk *guiWidget) drawView() {
tk.v.SelFgColor = tk.color.selFg
tk.v.SelBgColor = tk.color.selBg
}
log.Log(INFO, "drawView() END")
}