trap toolkit panics

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-30 03:17:15 -06:00
parent 00a0184918
commit 21836a8001
6 changed files with 44 additions and 21 deletions

19
main.go
View File

@ -6,6 +6,7 @@ package main
import (
"os"
"runtime/debug"
"go.wit.com/log"
"go.wit.com/toolkits/tree"
@ -30,7 +31,7 @@ func init() {
log.Log(NOW, "Init() start pluginChan")
// go catchActionChannel()
log.Sleep(.1) // probably not needed, but in here for now under development
go main()
go mainGogui()
log.Sleep(.1) // probably not needed, but in here for now under development
}
@ -58,6 +59,19 @@ func standardExit() {
var outf *os.File
func main() {
}
func mainGogui() {
defer func() {
if r := recover(); r != nil {
log.Warn("YAHOOOO Recovered in guiMain application:", r)
log.Warn("Recovered from panic:", r)
log.Warn("Stack trace:")
debug.PrintStack()
me.myTree.SendToolkitPanic()
return
}
}()
var err error
log.Log(INFO, "main() start Init()")
@ -75,7 +89,4 @@ func main() {
ferr, _ := os.OpenFile("/tmp/witgui.err", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0664)
os.Stderr = ferr
gocuiMain()
log.Log(NOW, "MouseMain() closed")
standardExit()
}

24
size.go
View File

@ -22,7 +22,9 @@ func (tk *guiWidget) Size() (int, int) {
var maxH int = 0
var maxW int = 0
for _, child := range tk.children {
if tk.hidden { continue }
if tk.hidden {
continue
}
sizeW, sizeH := child.Size()
maxW += sizeW
if sizeH > maxH {
@ -41,7 +43,9 @@ func (tk *guiWidget) Size() (int, int) {
maxH := tk.gocuiSize.Height()
for _, child := range tk.children {
if tk.hidden { continue }
if tk.hidden {
continue
}
sizeW, sizeH := child.Size()
// increment straight down
@ -59,11 +63,15 @@ func (tk *guiWidget) Size() (int, int) {
}
func (w *guiWidget) sizeGrid() (int, int) {
if w.hidden { return 0, 0 }
if w.hidden {
return 0, 0
}
// first compute the max sizes of the rows and columns
for _, child := range w.children {
if w.hidden { continue }
if w.hidden {
continue
}
sizeW, sizeH := child.Size()
// set the child's realWidth, and grid offset
@ -91,12 +99,16 @@ func (w *guiWidget) sizeBox() (int, int) {
if w.WidgetType != widget.Box {
return 0, 0
}
if w.hidden { return 0, 0 }
if w.hidden {
return 0, 0
}
var maxW int = 0
var maxH int = 0
for _, child := range w.children {
if w.hidden {continue}
if w.hidden {
continue
}
sizeW, sizeH := child.Size()
if child.direction == widget.Horizontal {
maxW += sizeW