save settings when window closing to avoid losing some settings on crash-exits
This commit is contained in:
+4
-2
@@ -336,16 +336,18 @@ func (a *App) DeleteServerCacheDir(serverID uuid.UUID) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) Shutdown() {
|
func (a *App) Shutdown() {
|
||||||
|
a.Config.LocalPlayback.Volume = a.LocalPlayer.GetVolume()
|
||||||
|
a.SavePlayQueueIfEnabled()
|
||||||
|
a.SaveConfigFile()
|
||||||
|
|
||||||
if a.ipcServer != nil {
|
if a.ipcServer != nil {
|
||||||
a.ipcServer.Shutdown(a.bgrndCtx)
|
a.ipcServer.Shutdown(a.bgrndCtx)
|
||||||
}
|
}
|
||||||
a.MPRISHandler.Shutdown()
|
a.MPRISHandler.Shutdown()
|
||||||
a.PlaybackManager.DisableCallbacks()
|
a.PlaybackManager.DisableCallbacks()
|
||||||
a.PlaybackManager.Stop() // will trigger scrobble check
|
a.PlaybackManager.Stop() // will trigger scrobble check
|
||||||
a.Config.LocalPlayback.Volume = a.LocalPlayer.GetVolume()
|
|
||||||
a.cancel()
|
a.cancel()
|
||||||
a.LocalPlayer.Destroy()
|
a.LocalPlayer.Destroy()
|
||||||
a.Config.WriteConfigFile(a.configFilePath())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) SavePlayQueueIfEnabled() {
|
func (a *App) SavePlayQueueIfEnabled() {
|
||||||
|
|||||||
+7
-1
@@ -140,8 +140,14 @@ func NewMainWindow(fyneApp fyne.App, appName, displayAppName, appVersion string,
|
|||||||
m.Window.SetContent(fynetooltip.AddWindowToolTipLayer(m.container, m.Window.Canvas()))
|
m.Window.SetContent(fynetooltip.AddWindowToolTipLayer(m.container, m.Window.Canvas()))
|
||||||
m.setInitialSize()
|
m.setInitialSize()
|
||||||
m.Window.SetCloseIntercept(func() {
|
m.Window.SetCloseIntercept(func() {
|
||||||
app.SavePlayQueueIfEnabled()
|
|
||||||
m.SaveWindowSize()
|
m.SaveWindowSize()
|
||||||
|
// save settings in case we crash during shutdown
|
||||||
|
// TODO: when all shutdowns exit cleanly, remove these lines
|
||||||
|
// as they are already executed in app.Shutdown()
|
||||||
|
app.Config.LocalPlayback.Volume = app.LocalPlayer.GetVolume()
|
||||||
|
app.SavePlayQueueIfEnabled()
|
||||||
|
app.SaveConfigFile()
|
||||||
|
|
||||||
if app.Config.Application.CloseToSystemTray && m.HaveSystemTray() {
|
if app.Config.Application.CloseToSystemTray && m.HaveSystemTray() {
|
||||||
m.Window.Hide()
|
m.Window.Hide()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user