From e3cea065580dd1b5855f2860d7d21d545ec59790 Mon Sep 17 00:00:00 2001 From: Dorian Zedler Date: Thu, 30 Jul 2020 12:12:44 +0200 Subject: [PATCH] fixed non working settings write --- ScStwLibraries/sources/scstwsettings.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ScStwLibraries/sources/scstwsettings.cpp b/ScStwLibraries/sources/scstwsettings.cpp index 81c843c..fa372ea 100644 --- a/ScStwLibraries/sources/scstwsettings.cpp +++ b/ScStwLibraries/sources/scstwsettings.cpp @@ -74,14 +74,21 @@ bool ScStwSettings::setDefaultSetting(int key, int keyLevel, QVariant defaultVal QVariant ScStwSettings::readSetting(QString key, int keyInt, int keyLevel) { Q_UNUSED(keyInt) Q_UNUSED(keyLevel) - return this->settingsCache[key]; + + if(this->settingsCache.contains(key)) + return this->settingsCache[key]; + else + return QVariant(); } bool ScStwSettings::writeSetting(QString key, QVariant value, int keyInt, int keyLevel) { - if(!this->keyToTypeConverters.contains(keyInt) || !value.convert(this->keyToTypeConverters[keyLevel](keyInt)) || value.type() == QVariant::Invalid) { + + // check if the value type is valid + if(!this->keyToTypeConverters.contains(keyLevel) || !value.convert(this->keyToTypeConverters[keyLevel](keyInt)) || value.type() == QVariant::Invalid) { return false; } + // write the setting if(!this->settingsCache.contains(key)) this->settingsCache.insert(key, value); else if (this->settingsCache[key] == value)