File tree Expand file tree Collapse file tree 3 files changed +18
-29
lines changed Expand file tree Collapse file tree 3 files changed +18
-29
lines changed Original file line number Diff line number Diff line change @@ -90,5 +90,7 @@ func runScript(name, script string) {
90
90
}
91
91
92
92
func watchTheme (s * settings ) {
93
- go internalapp .WatchTheme (s .setupTheme )
93
+ go internalapp .WatchTheme (func () {
94
+ fyne .Do (s .setupTheme )
95
+ })
94
96
}
Original file line number Diff line number Diff line change @@ -81,14 +81,12 @@ func (s *settings) ThemeVariant() fyne.ThemeVariant {
81
81
return s .variant
82
82
}
83
83
84
- // must be called from main goroutine
85
84
func (s * settings ) applyTheme (theme fyne.Theme , variant fyne.ThemeVariant ) {
86
85
s .variant = variant
87
86
s .theme = theme
88
87
s .apply ()
89
88
}
90
89
91
- // must be called from main goroutine
92
90
func (s * settings ) applyVariant (variant fyne.ThemeVariant ) {
93
91
s .variant = variant
94
92
s .apply ()
@@ -168,13 +166,7 @@ func (s *settings) setupTheme() {
168
166
variant = theme .VariantDark
169
167
}
170
168
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 )
178
170
}
179
171
180
172
func loadSettings () * settings {
Original file line number Diff line number Diff line change @@ -99,15 +99,24 @@ func (d *gLDriver) runGL() {
99
99
if d .trayStart != nil {
100
100
d .trayStart ()
101
101
}
102
- if f := fyne .CurrentApp ().Lifecycle ().(* app.Lifecycle ).OnStarted (); f != nil {
103
- f ()
104
- }
105
102
106
- var pendingSettings fyne.Settings
107
103
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
+ })
109
114
})
110
115
116
+ if f := fyne .CurrentApp ().Lifecycle ().(* app.Lifecycle ).OnStarted (); f != nil {
117
+ f ()
118
+ }
119
+
111
120
eventTick := time .NewTicker (time .Second / 60 )
112
121
for {
113
122
select {
@@ -156,20 +165,6 @@ func (d *gLDriver) runGL() {
156
165
d .animation .TickAnimations ()
157
166
d .drawSingleFrame ()
158
167
}
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
- }
173
168
}
174
169
}
175
170
You can’t perform that action at this time.
0 commit comments