diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2017-06-08 11:00:41 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-06-08 11:48:54 +0200 |
commit | 8a5837467d153c50c869625390a584b0335b77b7 (patch) | |
tree | d8aca950cb88dfdc3a001a5cdedf02d7a8894d36 /src/imports/settings/qqmlsettings.cpp | |
parent | 5af4c9b237a23ce12ca7c56eb6c9ecda17743228 (diff) | |
parent | 55490690f81eba168b06a90e4a66cefc20b38252 (diff) |
Merge remote-tracking branch 'origin/dev' into wip/scenegraphng
Conflicts:
src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode.cpp
Change-Id: Id8107cb0de0fbfe7120a90a137b49c2b915ff2d3
Diffstat (limited to 'src/imports/settings/qqmlsettings.cpp')
-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) { |