diff --git a/src/main.cpp b/src/main.cpp index 133f80bbad..9082e560a9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -929,7 +929,7 @@ int main ( int argc, char** argv ) bMuteMeInPersonalMix ); // load settings from init-file (command line options override) - CClientSettings Settings ( &Client, strIniFileName, pApp, bUseGUI ); + CClientSettings Settings ( &Client, strIniFileName ); Settings.Load ( CommandLineOptions ); # ifndef NO_JSON_RPC @@ -1011,7 +1011,7 @@ int main ( int argc, char** argv ) if ( bUseGUI ) { // load settings from init-file (command line options override) - CServerSettings Settings ( &Server, strIniFileName, pApp, bUseGUI ); + CServerSettings Settings ( &Server, strIniFileName ); Settings.Load ( CommandLineOptions ); // load translation diff --git a/src/settings.h b/src/settings.h index 95ebba7d16..619f666761 100644 --- a/src/settings.h +++ b/src/settings.h @@ -45,7 +45,7 @@ class CSettings : public QObject Q_OBJECT public: - CSettings ( const QCoreApplication* pApp, const bool bUseGUI ) : + CSettings() : vecWindowPosMain(), // empty array strLanguage ( "" ), strFileName ( "" ) @@ -53,10 +53,12 @@ class CSettings : public QObject QObject::connect ( QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, &CSettings::OnAboutToQuit ); #ifndef HEADLESS - if ( bUseGUI ) - { - const QGuiApplication* pGApp = static_cast ( pApp ); + // The Jamulus App will be created as either a QCoreApplication or QApplication (a subclass of QGuiApplication). + // State signals are only delivered to QGuiApplications, so we determine here whether we instantiated the GUI. + const QGuiApplication* pGApp = dynamic_cast ( QCoreApplication::instance() ); + if ( pGApp != nullptr ) + { QObject::connect ( pGApp, &QGuiApplication::saveStateRequest, this, [=] ( QSessionManager& ) { Save(); } ); QObject::connect ( pGApp, &QGuiApplication::applicationStateChanged, this, [=] ( Qt::ApplicationState state ) { @@ -129,8 +131,8 @@ public slots: class CClientSettings : public CSettings { public: - CClientSettings ( CClient* pNCliP, const QString& sNFiName, const QCoreApplication* pApp, const bool bUseGUI ) : - CSettings ( pApp, bUseGUI ), + CClientSettings ( CClient* pNCliP, const QString& sNFiName ) : + CSettings(), vecStoredFaderTags ( MAX_NUM_STORED_FADER_SETTINGS, "" ), vecStoredFaderLevels ( MAX_NUM_STORED_FADER_SETTINGS, AUD_MIX_FADER_MAX ), vecStoredPanValues ( MAX_NUM_STORED_FADER_SETTINGS, AUD_MIX_PAN_MAX / 2 ), @@ -206,9 +208,7 @@ class CClientSettings : public CSettings class CServerSettings : public CSettings { public: - CServerSettings ( CServer* pNSerP, const QString& sNFiName, const QCoreApplication* pApp, const bool bUseGUI ) : - CSettings ( pApp, bUseGUI ), - pServer ( pNSerP ) + CServerSettings ( CServer* pNSerP, const QString& sNFiName ) : CSettings(), pServer ( pNSerP ) { SetFileName ( sNFiName, DEFAULT_INI_FILE_NAME_SERVER ); }