From 241f672d3cd93e080bf35e3c0657897674e1e264 Mon Sep 17 00:00:00 2001 From: Craig Watson Date: Mon, 14 Mar 2016 10:42:00 +0100 Subject: [PATCH] Fixed force load of all settings The previous solution didn't really have any effect; only a handful of settings were in the mUserSettings or mAppSettings at the moment it was called. The better solution is to just call value() in the constructor of UBSetting, which means the setting is cached as soon as it is created. --- src/core/UBSetting.cpp | 2 +- src/core/UBSettings.cpp | 19 ------------------- src/core/UBSettings.h | 1 - 3 files changed, 1 insertion(+), 21 deletions(-) diff --git a/src/core/UBSetting.cpp b/src/core/UBSetting.cpp index 47b70cdf..8cedb8f0 100644 --- a/src/core/UBSetting.cpp +++ b/src/core/UBSetting.cpp @@ -48,7 +48,7 @@ UBSetting::UBSetting(UBSettings* owner, const QString& pDomain, const QString& p mPath(pDomain + "/" + pKey), mDefaultValue(pDefaultValue) { - //NOOP + get(); // force caching of the setting } UBSetting::~UBSetting() diff --git a/src/core/UBSettings.cpp b/src/core/UBSettings.cpp index 85683459..7901f8b1 100644 --- a/src/core/UBSettings.cpp +++ b/src/core/UBSettings.cpp @@ -126,7 +126,6 @@ UBSettings* UBSettings::settings() { if (!sSingleton) { sSingleton = new UBSettings(qApp); - sSingleton->load(); } return sSingleton; } @@ -492,24 +491,6 @@ void UBSettings::save() qDebug() << "User settings saved"; } -/** - * @brief Force load all settings, to cut down on subsequent file access - */ -void UBSettings::load() -{ - qDebug() << "Loading all settings"; - - QStringList keyList = mUserSettings->allKeys() + sAppSettings->allKeys(); - - keyList.removeDuplicates(); - - foreach(const QString& key, keyList) { - value(key); - // value() actually handles saving the value to the queue, so - // we don't need to do it here - } -} - int UBSettings::penWidthIndex() { return value("Board/PenLineWidthIndex", 0).toInt(); diff --git a/src/core/UBSettings.h b/src/core/UBSettings.h index f395a70f..900c1d8c 100644 --- a/src/core/UBSettings.h +++ b/src/core/UBSettings.h @@ -58,7 +58,6 @@ class UBSettings : public QObject void ValidateKeyboardPaletteKeyBtnSize(); void closing(); void save(); - void load(); int penWidthIndex();