Skip to content

Commit

Permalink
Try with dynamic case idiom
Browse files Browse the repository at this point in the history
  • Loading branch information
pljones committed Feb 18, 2024
1 parent c59b21a commit 4d87fbf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,20 @@ class CSettings : public QObject
Q_OBJECT

public:
CSettings ( const QCoreApplication* pApp, const bool bUseGUI ) :
CSettings() :
vecWindowPosMain(), // empty array
strLanguage ( "" ),
strFileName ( "" )
{
QObject::connect ( QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, &CSettings::OnAboutToQuit );

#ifndef HEADLESS
if ( bUseGUI )
{
const QGuiApplication* pGApp = static_cast<const QGuiApplication*> ( 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<const QGuiApplication*> ( QCoreApplication::instance() );

if ( pGApp != nullptr )
{
QObject::connect ( pGApp, &QGuiApplication::saveStateRequest, this, [=] ( QSessionManager& ) { Save(); } );

QObject::connect ( pGApp, &QGuiApplication::applicationStateChanged, this, [=] ( Qt::ApplicationState state ) {
Expand Down Expand Up @@ -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 ),
Expand Down Expand Up @@ -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 );
}
Expand Down

0 comments on commit 4d87fbf

Please sign in to comment.