Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes 3287: Only deregister on quit #3302

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ void CSettings::Load ( const QList<QString>& 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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ) );
Expand Down Expand Up @@ -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 );
}
}
14 changes: 7 additions & 7 deletions src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,29 +64,29 @@ 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 );
}
} );
}
#endif
}

void Load ( const QList<QString>& 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<QString>& CommandLineOptions ) = 0;

void ReadFromFile ( const QString& strCurFileName, QDomDocument& XMLDocument );
Expand Down Expand Up @@ -131,7 +131,7 @@ class CSettings : public QObject
QString strFileName;

public slots:
void OnAboutToQuit() { Save(); }
void OnAboutToQuit() { Save ( true ); }
};

#ifndef SERVER_ONLY
Expand Down Expand Up @@ -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<QString>& ) override;

void ReadFaderSettingsFromXML ( const QDomDocument& IniXMLDocument );
Expand All @@ -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<QString>& CommandLineOptions ) override;

CServer* pServer;
Expand Down