nil check in wrong place

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-02-09 09:48:40 -06:00
parent 0f9b7ec2af
commit 12829e6e1c
1 changed files with 10 additions and 5 deletions

15
init.go
View File

@ -14,11 +14,6 @@ var muAction sync.Mutex
// TODO: add checks for nil function pointers
func (me *TreeInfo) newAction(a widget.Action) {
n := me.treeRoot.FindWidgetId(a.WidgetId)
if n == nil {
log.Log(TREEWARN, "tree.FindWidgetId() n == nil", a.WidgetId, a.WidgetType, a.ActionType)
log.Log(TREEWARN, "tree.FindWidgetId() n == nil", a.State.CurrentS)
log.Log(TREEWARN, "tree.FindWidgetId() n == nil. This should not happen. Bug in gui or tree package?")
}
switch a.ActionType {
case widget.Add:
if n == nil {
@ -26,6 +21,16 @@ func (me *TreeInfo) newAction(a widget.Action) {
me.Add(n)
return
}
log.Log(TREEWARN, "attempting to re-add widget", a.WidgetId, a.WidgetType, a.ActionType)
return
}
if n == nil {
log.Log(TREEWARN, "tree.FindWidgetId() n == nil", a.WidgetId, a.WidgetType, a.ActionType)
log.Log(TREEWARN, "tree.FindWidgetId() n == nil", a.State.CurrentS)
log.Log(TREEWARN, "tree.FindWidgetId() n == nil. This should not happen. Bug in gui or tree package?")
// return
}
switch a.ActionType {
case widget.SetText:
log.Log(TREE, "tree.SetText() a.State.CurrentS =", a.State.CurrentS)
log.Log(TREE, "tree.SetText() a.State.DefaultS =", a.State.DefaultS)