defensive nil checks around CanvasForObject

This commit is contained in:
Drew Weymouth
2026-03-01 08:24:16 -08:00
parent 12b5d33bbe
commit afb1c6c397
8 changed files with 30 additions and 13 deletions
+4 -3
View File
@@ -67,7 +67,9 @@ func (g *FocusList) FocusNeighbor(curItem widget.ListItemID, up bool) {
other := g.ItemForID(focusIdx)
g.mutex.Unlock()
if other != nil {
fyne.CurrentApp().Driver().CanvasForObject(g).Focus(other.(fyne.Focusable))
if c := fyne.CurrentApp().Driver().CanvasForObject(g); c != nil {
c.Focus(other.(fyne.Focusable))
}
}
}
@@ -120,8 +122,7 @@ func (l *FocusListRowBase) SetItemID(id widget.ListItemID) {
func (l *FocusListRowBase) EnsureUnfocused() {
if l.Focused {
c := fyne.CurrentApp().Driver().CanvasForObject(l)
if c != nil {
if c := fyne.CurrentApp().Driver().CanvasForObject(l); c != nil {
c.Unfocus()
}
}