diff --git a/src/settings.cpp b/src/settings.cpp index 89291fd6a4..ab54422a19 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -36,13 +36,13 @@ void CSettings::Load ( const QList& CommandLineOptions ) ReadSettingsFromXML ( IniXMLDocument, CommandLineOptions ); } -void CSettings::Save() +void CSettings::Save ( bool isAboutToQuit ) { // create XML document for storing initialization parameters QDomDocument IniXMLDocument; // write the settings in the XML file - WriteSettingsToXML ( IniXMLDocument ); + WriteSettingsToXML ( IniXMLDocument, isAboutToQuit ); // prepare file name for storing initialization data in XML file and store // XML data in file @@ -614,8 +614,9 @@ void CClientSettings::ReadFaderSettingsFromXML ( const QDomDocument& IniXMLDocum } } -void CClientSettings::WriteSettingsToXML ( QDomDocument& IniXMLDocument ) +void CClientSettings::WriteSettingsToXML ( QDomDocument& IniXMLDocument, bool isAboutToQuit ) { + Q_UNUSED ( isAboutToQuit ) int iIdx; // IP addresses @@ -944,7 +945,7 @@ void CServerSettings::ReadSettingsFromXML ( const QDomDocument& IniXMLDocument, } } -void CServerSettings::WriteSettingsToXML ( QDomDocument& IniXMLDocument ) +void CServerSettings::WriteSettingsToXML ( QDomDocument& IniXMLDocument, bool isAboutToQuit ) { // window position of the main window PutIniSetting ( IniXMLDocument, "server", "winposmain_base64", ToBase64 ( vecWindowPosMain ) ); @@ -985,6 +986,9 @@ void CServerSettings::WriteSettingsToXML ( QDomDocument& IniXMLDocument ) // delay panning SetFlagIniSet ( IniXMLDocument, "server", "delaypan", pServer->IsDelayPanningEnabled() ); - // we MUST do this after saving the value and Save() is only called OnAboutToQuit() - pServer->SetDirectoryType ( AT_NONE ); + // we MUST do this after saving the value and Save() is called OnAboutToQuit() + if ( isAboutToQuit ) + { + pServer->SetDirectoryType ( AT_NONE ); + } } diff --git a/src/settings.h b/src/settings.h index 3fe2b72a19..a7d7564519 100644 --- a/src/settings.h +++ b/src/settings.h @@ -64,14 +64,14 @@ class CSettings : public QObject pGApp, &QGuiApplication::saveStateRequest, this, - [=] ( QSessionManager& ) { Save(); }, + [=] ( QSessionManager& ) { Save ( false ); }, Qt::DirectConnection ); # endif QObject::connect ( pGApp, &QGuiApplication::applicationStateChanged, this, [=] ( Qt::ApplicationState state ) { if ( Qt::ApplicationActive != state ) { - Save(); + Save ( false ); } } ); } @@ -79,14 +79,14 @@ class CSettings : public QObject } void Load ( const QList& CommandLineOptions ); - void Save(); + void Save ( bool isAboutToQuit ); // common settings QByteArray vecWindowPosMain; QString strLanguage; protected: - virtual void WriteSettingsToXML ( QDomDocument& IniXMLDocument ) = 0; + virtual void WriteSettingsToXML ( QDomDocument& IniXMLDocument, bool isAboutToQuit ) = 0; virtual void ReadSettingsFromXML ( const QDomDocument& IniXMLDocument, const QList& CommandLineOptions ) = 0; void ReadFromFile ( const QString& strCurFileName, QDomDocument& XMLDocument ); @@ -131,7 +131,7 @@ class CSettings : public QObject QString strFileName; public slots: - void OnAboutToQuit() { Save(); } + void OnAboutToQuit() { Save ( true ); } }; #ifndef SERVER_ONLY @@ -202,7 +202,7 @@ class CClientSettings : public CSettings bool bOwnFaderFirst; protected: - virtual void WriteSettingsToXML ( QDomDocument& IniXMLDocument ) override; + virtual void WriteSettingsToXML ( QDomDocument& IniXMLDocument, bool isAboutToQuit ) override; virtual void ReadSettingsFromXML ( const QDomDocument& IniXMLDocument, const QList& ) override; void ReadFaderSettingsFromXML ( const QDomDocument& IniXMLDocument ); @@ -221,7 +221,7 @@ class CServerSettings : public CSettings } protected: - virtual void WriteSettingsToXML ( QDomDocument& IniXMLDocument ) override; + virtual void WriteSettingsToXML ( QDomDocument& IniXMLDocument, bool isAboutToQuit ) override; virtual void ReadSettingsFromXML ( const QDomDocument& IniXMLDocument, const QList& CommandLineOptions ) override; CServer* pServer;