aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/types
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-10-22 08:14:28 +0200
committerUlf Hermann <ulf.hermann@qt.io>2021-10-22 20:48:33 +0200
commit51694e7b5b8feb466e3760ca46bd29c14de7590e (patch)
tree193597ff0939b04685e2467e627a121565e09ee2 /src/qml/types
parentee469d528a350f1fbcebc12a3728f7ed6f4a1302 (diff)
Make QQmlBind::value a QVariant again
This partially reverts commit 00f903f3b4cd46ddf8361876401e5405030f97f1. We don't need the QJSValue to protect against magic conversions anymore since magic conversions have been removed in commit 1b7a098803a43355abf62e099267d4a122645e07. Change-Id: I3e60d8562d409144cdb921060c2736b1f8278e2b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Diffstat (limited to 'src/qml/types')
-rw-r--r--src/qml/types/qqmlbind.cpp13
-rw-r--r--src/qml/types/qqmlbind_p.h6
2 files changed, 12 insertions, 7 deletions
diff --git a/src/qml/types/qqmlbind.cpp b/src/qml/types/qqmlbind.cpp
index 5c5bbefb43..b8adcb1d2f 100644
--- a/src/qml/types/qqmlbind.cpp
+++ b/src/qml/types/qqmlbind.cpp
@@ -82,7 +82,12 @@ public:
QQmlNullableValue<bool> when;
QPointer<QObject> obj;
QString propName;
- QQmlNullableValue<QJSValue> value;
+
+ // An invalid QVariant has special semantics that you may explicitly want when writing the
+ // value. Therefore we need to denote "is not set" in a different way. We do this by wrapping
+ // the value in QQmlNullableValue.
+ QQmlNullableValue<QVariant> value;
+
QQmlProperty prop;
QQmlAnyBinding prevBind;
QV4::PersistentValue v4Value;
@@ -296,13 +301,13 @@ void QQmlBind::setProperty(const QString &p)
The value to be set on the target object and property. This can be a
constant (which isn't very useful), or a bound expression.
*/
-QJSValue QQmlBind::value() const
+QVariant QQmlBind::value() const
{
Q_D(const QQmlBind);
return d->value.value;
}
-void QQmlBind::setValue(const QJSValue &v)
+void QQmlBind::setValue(const QVariant &v)
{
Q_D(QQmlBind);
d->value = v;
@@ -512,7 +517,7 @@ void QQmlBind::eval()
}
d->writingProperty = true;
- d->prop.write(d->value.value.toVariant());
+ d->prop.write(d->value.value);
d->writingProperty = false;
}
diff --git a/src/qml/types/qqmlbind_p.h b/src/qml/types/qqmlbind_p.h
index 63e8e8b92a..e0f70f75c7 100644
--- a/src/qml/types/qqmlbind_p.h
+++ b/src/qml/types/qqmlbind_p.h
@@ -76,7 +76,7 @@ private:
Q_INTERFACES(QQmlPropertyValueSource)
Q_PROPERTY(QObject *target READ object WRITE setObject)
Q_PROPERTY(QString property READ property WRITE setProperty)
- Q_PROPERTY(QJSValue value READ value WRITE setValue)
+ Q_PROPERTY(QVariant value READ value WRITE setValue)
Q_PROPERTY(bool when READ when WRITE setWhen)
Q_PROPERTY(bool delayed READ delayed WRITE setDelayed REVISION(2, 8))
Q_PROPERTY(RestorationMode restoreMode READ restoreMode WRITE setRestoreMode
@@ -97,8 +97,8 @@ public:
QString property() const;
void setProperty(const QString &);
- QJSValue value() const;
- void setValue(const QJSValue &);
+ QVariant value() const;
+ void setValue(const QVariant &);
bool delayed() const;
void setDelayed(bool);