From 5bafd65538a877e8f186fc44d03d4b2c705820f3 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 3 Nov 2017 19:45:41 +0300 Subject: 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. --- settings.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3