diff options
Diffstat (limited to 'src/qml/types')
-rw-r--r-- | src/qml/types/qqmlbind.cpp | 23 | ||||
-rw-r--r-- | src/qml/types/qqmlbind_p.h | 6 |
2 files changed, 21 insertions, 8 deletions
diff --git a/src/qml/types/qqmlbind.cpp b/src/qml/types/qqmlbind.cpp index 9d305cd24c..36de16a818 100644 --- a/src/qml/types/qqmlbind.cpp +++ b/src/qml/types/qqmlbind.cpp @@ -78,7 +78,7 @@ public: QQmlNullableValue<bool> when; QPointer<QObject> obj; QString propName; - QQmlNullableValue<QVariant> value; + QQmlNullableValue<QJSValue> value; QQmlProperty prop; QQmlAbstractBinding::Ptr prevBind; QV4::PersistentValue v4Value; @@ -293,13 +293,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. */ -QVariant QQmlBind::value() const +QJSValue QQmlBind::value() const { Q_D(const QQmlBind); return d->value.value; } -void QQmlBind::setValue(const QVariant &v) +void QQmlBind::setValue(const QJSValue &v) { Q_D(QQmlBind); d->value = v; @@ -359,7 +359,8 @@ void QQmlBind::setDelayed(bool delayed) \li Binding.RestoreBindingOrValue The original value is always restored. \endlist - The default value is Binding.RestoreBinding. + \warning The default value is Binding.RestoreBinding. This will change in + Qt 5.15 to Binding.RestoreBindingOrValue. If you rely on any specific behavior regarding the restoration of plain values when bindings get disabled you should migrate to explicitly set the @@ -456,11 +457,23 @@ void QQmlBind::eval() Q_ASSERT(vmemo); vmemo->setVMEProperty(propPriv->core.coreIndex(), *d->v4Value.valueRef()); d->clearPrev(); + } else if (!d->restoreModeExplicit) { + qmlWarning(this) + << "Not restoring previous value because restoreMode has not been set." + << "This behavior is deprecated." + << "In Qt < 5.15 the default is Binding.RestoreBinding." + << "In Qt >= 5.15 the default is Binding.RestoreBindingOrValue."; } } else if (d->prevIsVariant) { if (d->restoreValue) { d->prop.write(d->prevValue); d->clearPrev(); + } else if (!d->restoreModeExplicit) { + qmlWarning(this) + << "Not restoring previous value because restoreMode has not been set." + << "This behavior is deprecated." + << "In Qt < 5.15 the default is Binding.RestoreBinding." + << "In Qt >= 5.15 the default is Binding.RestoreBindingOrValue."; } } return; @@ -489,7 +502,7 @@ void QQmlBind::eval() QQmlPropertyPrivate::removeBinding(d->prop); } - d->prop.write(d->value.value); + d->prop.write(d->value.value.toVariant()); } QT_END_NAMESPACE diff --git a/src/qml/types/qqmlbind_p.h b/src/qml/types/qqmlbind_p.h index e7c7e01a0d..a100b1552c 100644 --- a/src/qml/types/qqmlbind_p.h +++ b/src/qml/types/qqmlbind_p.h @@ -75,7 +75,7 @@ private: Q_INTERFACES(QQmlPropertyValueSource) Q_PROPERTY(QObject *target READ object WRITE setObject) Q_PROPERTY(QString property READ property WRITE setProperty) - Q_PROPERTY(QVariant value READ value WRITE setValue) + Q_PROPERTY(QJSValue value READ value WRITE setValue) Q_PROPERTY(bool when READ when WRITE setWhen) Q_PROPERTY(bool delayed READ delayed WRITE setDelayed REVISION 8) Q_PROPERTY(RestorationMode restoreMode READ restoreMode WRITE setRestoreMode @@ -96,8 +96,8 @@ public: QString property() const; void setProperty(const QString &); - QVariant value() const; - void setValue(const QVariant &); + QJSValue value() const; + void setValue(const QJSValue &); bool delayed() const; void setDelayed(bool); |