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.
preferencesAboutTextFull
Craig Watson 9 years ago
parent 39e020bbfa
commit 241f672d3c
  1. 2
      src/core/UBSetting.cpp
  2. 19
      src/core/UBSettings.cpp
  3. 1
      src/core/UBSettings.h

@ -48,7 +48,7 @@ UBSetting::UBSetting(UBSettings* owner, const QString& pDomain, const QString& p
mPath(pDomain + "/" + pKey), mPath(pDomain + "/" + pKey),
mDefaultValue(pDefaultValue) mDefaultValue(pDefaultValue)
{ {
//NOOP get(); // force caching of the setting
} }
UBSetting::~UBSetting() UBSetting::~UBSetting()

@ -126,7 +126,6 @@ UBSettings* UBSettings::settings()
{ {
if (!sSingleton) { if (!sSingleton) {
sSingleton = new UBSettings(qApp); sSingleton = new UBSettings(qApp);
sSingleton->load();
} }
return sSingleton; return sSingleton;
} }
@ -492,24 +491,6 @@ void UBSettings::save()
qDebug() << "User settings saved"; 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() int UBSettings::penWidthIndex()
{ {
return value("Board/PenLineWidthIndex", 0).toInt(); return value("Board/PenLineWidthIndex", 0).toInt();

@ -58,7 +58,6 @@ class UBSettings : public QObject
void ValidateKeyboardPaletteKeyBtnSize(); void ValidateKeyboardPaletteKeyBtnSize();
void closing(); void closing();
void save(); void save();
void load();
int penWidthIndex(); int penWidthIndex();

Loading…
Cancel
Save