Skip to content

Commit

Permalink
widget: Make BaseWidget theme lookup code more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacalz committed Jan 9, 2025
1 parent 61e206b commit 6ecf5db
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions widget/widget.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,17 @@ func (w *BaseWidget) Refresh() {
// Since: 2.5
func (w *BaseWidget) Theme() fyne.Theme {
cached := w.themeCache
if cached == nil {
cached = cache.WidgetTheme(w.super())
// don't cache the default as it may change
if cached == nil {
return theme.Current()
}
if cached != nil {
return cached
}

w.themeCache = cached
cached = cache.WidgetTheme(w.super())
// don't cache the default as it may change
if cached == nil {
return theme.Current()
}

w.themeCache = cached
return cached
}

Expand Down

0 comments on commit 6ecf5db

Please sign in to comment.