diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-11-03 19:45:41 +0300 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-11-03 19:45:41 +0300 |
commit | 5bafd65538a877e8f186fc44d03d4b2c705820f3 (patch) | |
tree | d5931726b3d8b1407e08aa8ffe9a721f12991c6d /settings.cpp | |
parent | 02fa295085ae2297062d10f476a0b40b7fcb2559 (diff) | |
download | libquotient-5bafd65538a877e8f186fc44d03d4b2c705820f3.tar.gz libquotient-5bafd65538a877e8f186fc44d03d4b2c705820f3.zip |
Settings: Catch literal "false" values stored by Qt.labs.Settings QML module
Those stand for a boolean false value in Qt.labs.Settings, but plain JavaScript thinks that "false" == true so if you take a value through QMatrixClient::Settings instead of Qt.labs.Settings, you would get screwed.
Diffstat (limited to 'settings.cpp')
-rw-r--r-- | settings.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/settings.cpp b/settings.cpp index 98921869..68914642 100644 --- a/settings.cpp +++ b/settings.cpp @@ -23,7 +23,13 @@ void Settings::setValue(const QString& key, const QVariant& value) QVariant Settings::value(const QString& key, const QVariant& defaultValue) const
{
- return QSettings::value(key, legacySettings.value(key, defaultValue));
+ auto value = QSettings::value(key, legacySettings.value(key, defaultValue));
+ // QML's Qt.labs.Settings stores boolean values as strings, which, if loaded
+ // through the usual QSettings interface, confuses QML
+ // (QVariant("false") == true in JavaScript). Since we have a mixed
+ // environment where both QSettings and Qt.labs.Settings may potentially
+ // work with same settings, better ensure compatibility.
+ return value.toString() == QStringLiteral("false") ? QVariant(false) : value;
}
bool Settings::contains(const QString& key) const
|