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)