all repos — mgba @ c11551a1f7809c4f434230fb18b624f6cddea062

mGBA Game Boy Advance Emulator

Qt: Make ConfigController::configDir static
Vicki Pfau vi@endrift.com
Wed, 18 Jan 2017 01:36:06 -0800
commit

c11551a1f7809c4f434230fb18b624f6cddea062

parent

22a36e0af9646f5c4456dd42d4dad039cb36d825

M src/platform/qt/ConfigController.cppsrc/platform/qt/ConfigController.cpp

@@ -88,14 +88,13 @@ slot(value);

} } +QString ConfigController::s_configDir; + ConfigController::ConfigController(QObject* parent) : QObject(parent) , m_opts() { - char path[PATH_MAX]; - mCoreConfigDirectory(path, sizeof(path)); - m_configDir = QString::fromUtf8(path); - QString fileName = (m_configDir); + QString fileName = configDir(); fileName.append(QDir::separator()); fileName.append("qt.ini"); m_settings = new QSettings(fileName, QSettings::IniFormat, this);

@@ -270,7 +269,7 @@

void ConfigController::makePortable() { mCoreConfigMakePortable(&m_config); - QString fileName(m_configDir); + QString fileName(configDir()); fileName.append(QDir::separator()); fileName.append("qt.ini"); QSettings* settings2 = new QSettings(fileName, QSettings::IniFormat, this);

@@ -280,3 +279,12 @@ }

delete m_settings; m_settings = settings2; } + +const QString& ConfigController::configDir() { + if (s_configDir.isNull()) { + char path[PATH_MAX]; + mCoreConfigDirectory(path, sizeof(path)); + s_configDir = QString::fromUtf8(path); + } + return s_configDir; +}
M src/platform/qt/ConfigController.hsrc/platform/qt/ConfigController.h

@@ -84,7 +84,7 @@ Configuration* input() { return mCoreConfigGetInput(&m_config); }

const mCoreConfig* config() { return &m_config; } - const QString& configDir() { return m_configDir; } + static const QString& configDir(); public slots: void setOption(const char* key, bool value);

@@ -105,7 +105,7 @@ mCoreOptions m_opts;

QMap<QString, ConfigOption*> m_optionSet; QSettings* m_settings; - QString m_configDir; + static QString s_configDir; }; }
M src/platform/qt/GBAApp.cppsrc/platform/qt/GBAApp.cpp

@@ -218,7 +218,7 @@

#ifdef USE_SQLITE3 bool GBAApp::reloadGameDB() { NoIntroDB* db = nullptr; - db = NoIntroDBLoad((m_configController.configDir() + "/nointro.sqlite3").toLocal8Bit().constData()); + db = NoIntroDBLoad((ConfigController::configDir() + "/nointro.sqlite3").toUtf8().constData()); if (db && m_db) { NoIntroDBDestroy(m_db); }