Skip to content

Commit

Permalink
Fix crash when applying theme early in app lifecycle
Browse files Browse the repository at this point in the history
Fixes #688
  • Loading branch information
andydotxyz committed Feb 24, 2020
1 parent 8537eec commit 3fb5037
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/app/theme.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import (
// ApplyThemeTo ensures that the specified canvasobject and all widgets and themeable objects will
// be updated for the current theme.
func ApplyThemeTo(content fyne.CanvasObject, canv fyne.Canvas) {
if content == nil {
return
}
if wid, ok := content.(fyne.Widget); ok {
for _, o := range cache.Renderer(wid).Objects() {
ApplyThemeTo(o, canv)
Expand Down
14 changes: 14 additions & 0 deletions internal/app/theme_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package app

import (
"testing"

"fyne.io/fyne/test"
)

func TestApplySettings_BeforeContentSet(t *testing.T) {
a := test.NewApp()
_ = a.NewWindow("NoContent")

ApplySettings(a.Settings(), a)
}

0 comments on commit 3fb5037

Please sign in to comment.