@@ -14,8 +14,6 @@ import (
14
14
"fyne.io/fyne/v2/internal/app"
15
15
intRepo "fyne.io/fyne/v2/internal/repository"
16
16
"fyne.io/fyne/v2/storage/repository"
17
-
18
- "golang.org/x/sys/execabs"
19
17
)
20
18
21
19
// Declare conformity with App interface
@@ -33,7 +31,6 @@ type fyneApp struct {
33
31
prefs fyne.Preferences
34
32
35
33
running uint32 // atomic, 1 == running, 0 == stopped
36
- exec func (name string , arg ... string ) * execabs.Cmd
37
34
}
38
35
39
36
func (a * fyneApp ) CloudProvider () fyne.CloudProvider {
@@ -72,7 +69,6 @@ func (a *fyneApp) NewWindow(title string) fyne.Window {
72
69
func (a * fyneApp ) Run () {
73
70
if atomic .CompareAndSwapUint32 (& a .running , 0 , 1 ) {
74
71
a .driver .Run ()
75
- return
76
72
}
77
73
}
78
74
@@ -110,10 +106,10 @@ func (a *fyneApp) Lifecycle() fyne.Lifecycle {
110
106
return a .lifecycle
111
107
}
112
108
113
- func (a * fyneApp ) newDefaultPreferences () fyne. Preferences {
114
- p := fyne . Preferences ( newPreferences (a ) )
115
- if pref , ok := p .( interface { load () }); ok && a .uniqueID != "" {
116
- pref .load ()
109
+ func (a * fyneApp ) newDefaultPreferences () * preferences {
110
+ p := newPreferences (a )
111
+ if a .uniqueID != "" {
112
+ p .load ()
117
113
}
118
114
return p
119
115
}
@@ -126,11 +122,8 @@ func New() fyne.App {
126
122
return NewWithID (meta .ID )
127
123
}
128
124
129
- func makeStoreDocs (id string , p fyne. Preferences , s * store ) * internal.Docs {
125
+ func makeStoreDocs (id string , s * store ) * internal.Docs {
130
126
if id != "" {
131
- if pref , ok := p .(interface { load () }); ok {
132
- pref .load ()
133
- }
134
127
err := os .MkdirAll (s .a .storageRoot (), 0755 ) // make the space before anyone can use it
135
128
if err != nil {
136
129
fyne .LogError ("Failed to create app storage space" , err )
@@ -144,21 +137,27 @@ func makeStoreDocs(id string, p fyne.Preferences, s *store) *internal.Docs {
144
137
}
145
138
146
139
func newAppWithDriver (d fyne.Driver , id string ) fyne.App {
147
- newApp := & fyneApp {uniqueID : id , driver : d , exec : execabs . Command , lifecycle : & app.Lifecycle {}}
140
+ newApp := & fyneApp {uniqueID : id , driver : d , lifecycle : & app.Lifecycle {}}
148
141
fyne .SetCurrentApp (newApp )
149
142
150
143
newApp .prefs = newApp .newDefaultPreferences ()
144
+ newApp .lifecycle .(* app.Lifecycle ).SetOnStoppedHookExecuted (func () {
145
+ if prefs , ok := newApp .prefs .(* preferences ); ok {
146
+ prefs .forceImmediateSave ()
147
+ }
148
+ })
151
149
newApp .settings = loadSettings ()
152
150
store := & store {a : newApp }
153
- store .Docs = makeStoreDocs (id , newApp . prefs , store )
151
+ store .Docs = makeStoreDocs (id , store )
154
152
newApp .storage = store
155
153
156
154
if ! d .Device ().IsMobile () {
157
155
newApp .settings .watchSettings ()
158
156
}
159
157
160
- repository .Register ("http" , intRepo .NewHTTPRepository ())
161
- repository .Register ("https" , intRepo .NewHTTPRepository ())
158
+ httpHandler := intRepo .NewHTTPRepository ()
159
+ repository .Register ("http" , httpHandler )
160
+ repository .Register ("https" , httpHandler )
162
161
163
162
return newApp
164
163
}
0 commit comments