Skip to content

Commit

Permalink
Corrected the callback variable name for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
nullst committed Jul 10, 2023
1 parent 86eb71f commit 982402e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func newAppWithDriver(d fyne.Driver, id string) fyne.App {
fyne.SetCurrentApp(newApp)

newApp.prefs = newApp.newDefaultPreferences()
newApp.lifecycle.(*app.Lifecycle).SetAfterStopped(func() {
newApp.lifecycle.(*app.Lifecycle).SetOnStoppedHookExecuted(func() {
if prefs, ok := newApp.prefs.(*preferences); ok {
prefs.forceImmediateSave()
}
Expand Down
1 change: 0 additions & 1 deletion app/preferences.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ func (p *preferences) saveToFile(path string) error {
p.savedRecently = true
p.prefLock.Unlock()
defer p.resetSavedRecently()

err := os.MkdirAll(filepath.Dir(path), 0700)
if err != nil { // this is not an exists error according to docs
return err
Expand Down
10 changes: 5 additions & 5 deletions internal/app/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ type Lifecycle struct {
onStarted atomic.Value // func()
onStopped atomic.Value // func()

internalAfterStoppedTrigger atomic.Value // func()
onStoppedHookExecuted atomic.Value // func()
}

// SetAfterStopped is an internal function that lets Fyne schedule a clean-up after
// SetOnStoppedHookExecuted is an internal function that lets Fyne schedule a clean-up after
// the user-provided stopped hook.
func (l *Lifecycle) SetAfterStopped(f func()) {
l.internalAfterStoppedTrigger.Store(f)
func (l *Lifecycle) SetOnStoppedHookExecuted(f func()) {
l.onStoppedHookExecuted.Store(f)
}

// SetOnEnteredForeground hooks into the the app becoming foreground.
Expand Down Expand Up @@ -79,7 +79,7 @@ func (l *Lifecycle) TriggerStopped() {
if ff, ok := f.(func()); ok && ff != nil {
ff()
}
f = l.internalAfterStoppedTrigger.Load()
f = l.onStoppedHookExecuted.Load()
if ff, ok := f.(func()); ok && ff != nil {
ff()
}
Expand Down

0 comments on commit 982402e

Please sign in to comment.