Qt: Make ConfigController::configDir static
Vicki Pfau vi@endrift.com
Wed, 18 Jan 2017 01:36:06 -0800
3 files changed,
16 insertions(+),
8 deletions(-)
M
src/platform/qt/ConfigController.cpp
→
src/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.h
→
src/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.cpp
→
src/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); }