diff options
author | Liang Qi <liang.qi@qt.io> | 2017-05-31 08:12:24 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-05-31 08:12:25 +0200 |
commit | 9f178cbe9ea27d247c82c7bbc396b1c3b264a06d (patch) | |
tree | 552cc5682fef1d046e9ad9394a22620bd380ad98 /src/imports | |
parent | 344fbc3d2f4ccc9773e2bbe7b2969b4ac86dc9aa (diff) | |
parent | 96f6ba5f562073f508cd8569ac354592fdd48f4a (diff) |
Merge remote-tracking branch 'origin/5.9.0' into 5.9
Change-Id: I3f77593ca944114534fff5df26bbb09150ee4400
Diffstat (limited to 'src/imports')
-rw-r--r-- | src/imports/settings/qqmlsettings.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/imports/settings/qqmlsettings.cpp b/src/imports/settings/qqmlsettings.cpp index cd6fcbc718..df67c04654 100644 --- a/src/imports/settings/qqmlsettings.cpp +++ b/src/imports/settings/qqmlsettings.cpp @@ -41,6 +41,7 @@ #include <qcoreevent.h> #include <qsettings.h> #include <qpointer.h> +#include <qjsvalue.h> #include <qdebug.h> #include <qhash.h> @@ -241,6 +242,7 @@ public: void store(); void _q_propertyChanged(); + QVariant readProperty(const QMetaProperty &property) const; QQmlSettings *q_ptr; int timerId; @@ -295,7 +297,7 @@ void QQmlSettingsPrivate::load() for (int i = offset; i < count; ++i) { QMetaProperty property = mo->property(i); - const QVariant previousValue = property.read(q); + const QVariant previousValue = readProperty(property); const QVariant currentValue = instance()->value(property.name(), previousValue); if (!currentValue.isNull() && (!previousValue.isValid() @@ -340,9 +342,10 @@ void QQmlSettingsPrivate::_q_propertyChanged() const int count = mo->propertyCount(); for (int i = offset; i < count; ++i) { const QMetaProperty &property = mo->property(i); - changedProperties.insert(property.name(), property.read(q)); + const QVariant value = readProperty(property); + changedProperties.insert(property.name(), value); #ifdef SETTINGS_DEBUG - qDebug() << "QQmlSettings: cache" << property.name() << ":" << property.read(q); + qDebug() << "QQmlSettings: cache" << property.name() << ":" << value; #endif } if (timerId != 0) @@ -350,6 +353,15 @@ void QQmlSettingsPrivate::_q_propertyChanged() timerId = q->startTimer(settingsWriteDelay); } +QVariant QQmlSettingsPrivate::readProperty(const QMetaProperty &property) const +{ + Q_Q(const QQmlSettings); + QVariant var = property.read(q); + if (var.userType() == qMetaTypeId<QJSValue>()) + var = var.value<QJSValue>().toVariant(); + return var; +} + QQmlSettings::QQmlSettings(QObject *parent) : QObject(parent), d_ptr(new QQmlSettingsPrivate) { |