Skip to content

Commit ac4e63a

Browse files
committed
address review comments
1 parent b6bf4d6 commit ac4e63a

File tree

3 files changed

+18
-29
lines changed

3 files changed

+18
-29
lines changed

app/app_windows.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,7 @@ func runScript(name, script string) {
9090
}
9191

9292
func watchTheme(s *settings) {
93-
go internalapp.WatchTheme(s.setupTheme)
93+
go internalapp.WatchTheme(func() {
94+
fyne.Do(s.setupTheme)
95+
})
9496
}

app/settings.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,12 @@ func (s *settings) ThemeVariant() fyne.ThemeVariant {
8181
return s.variant
8282
}
8383

84-
// must be called from main goroutine
8584
func (s *settings) applyTheme(theme fyne.Theme, variant fyne.ThemeVariant) {
8685
s.variant = variant
8786
s.theme = theme
8887
s.apply()
8988
}
9089

91-
// must be called from main goroutine
9290
func (s *settings) applyVariant(variant fyne.ThemeVariant) {
9391
s.variant = variant
9492
s.apply()
@@ -168,13 +166,7 @@ func (s *settings) setupTheme() {
168166
variant = theme.VariantDark
169167
}
170168

171-
if async.IsMainGoroutine() {
172-
s.applyTheme(effectiveTheme, variant)
173-
} else {
174-
fyne.Do(func() {
175-
s.applyTheme(effectiveTheme, variant)
176-
})
177-
}
169+
s.applyTheme(effectiveTheme, variant)
178170
}
179171

180172
func loadSettings() *settings {

internal/driver/glfw/loop.go

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,24 @@ func (d *gLDriver) runGL() {
9999
if d.trayStart != nil {
100100
d.trayStart()
101101
}
102-
if f := fyne.CurrentApp().Lifecycle().(*app.Lifecycle).OnStarted(); f != nil {
103-
f()
104-
}
105102

106-
var pendingSettings fyne.Settings
107103
fyne.CurrentApp().Settings().AddListener(func(set fyne.Settings) {
108-
pendingSettings = set
104+
painter.ClearFontCache()
105+
cache.ResetThemeCaches()
106+
app.ApplySettingsWithCallback(set, fyne.CurrentApp(), func(w fyne.Window) {
107+
c, ok := w.Canvas().(*glCanvas)
108+
if !ok {
109+
return
110+
}
111+
c.applyThemeOutOfTreeObjects()
112+
c.reloadScale()
113+
})
109114
})
110115

116+
if f := fyne.CurrentApp().Lifecycle().(*app.Lifecycle).OnStarted(); f != nil {
117+
f()
118+
}
119+
111120
eventTick := time.NewTicker(time.Second / 60)
112121
for {
113122
select {
@@ -156,20 +165,6 @@ func (d *gLDriver) runGL() {
156165
d.animation.TickAnimations()
157166
d.drawSingleFrame()
158167
}
159-
160-
if pendingSettings != nil {
161-
painter.ClearFontCache()
162-
cache.ResetThemeCaches()
163-
app.ApplySettingsWithCallback(pendingSettings, fyne.CurrentApp(), func(w fyne.Window) {
164-
c, ok := w.Canvas().(*glCanvas)
165-
if !ok {
166-
return
167-
}
168-
c.applyThemeOutOfTreeObjects()
169-
c.reloadScale()
170-
})
171-
pendingSettings = nil
172-
}
173168
}
174169
}
175170

0 commit comments

Comments
 (0)