From 62e3c7408061b76c9ca585651da4e45ac941fe87 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 9 Oct 2019 10:54:15 +0200 Subject: QQmlBinding: Change the restoreMode default As promised in 5.14 we now change the default to RestoreBindingOrValue. Update the documentation accordingly. [ChangeLog][Important Behavior Changes] By default Binding elements now restore values as well as bindings when they become inactive. Task-number: QTBUG-78566 Change-Id: Id5c0247eff253f37cc6714179601c4277d2de7d0 Reviewed-by: Fabian Kosmale Reviewed-by: Simon Hausmann --- src/qml/types/qqmlbind.cpp | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) (limited to 'src/qml/types/qqmlbind.cpp') diff --git a/src/qml/types/qqmlbind.cpp b/src/qml/types/qqmlbind.cpp index 921d60caa1..6d762401d0 100644 --- a/src/qml/types/qqmlbind.cpp +++ b/src/qml/types/qqmlbind.cpp @@ -73,8 +73,7 @@ public: , delayed(false) , pendingEval(false) , restoreBinding(true) - , restoreValue(false) - , restoreModeExplicit(false) + , restoreValue(true) , writingProperty(false) {} ~QQmlBindPrivate() { } @@ -93,7 +92,6 @@ public: bool pendingEval:1; bool restoreBinding:1; bool restoreValue:1; - bool restoreModeExplicit:1; bool writingProperty: 1; void validate(QObject *binding) const; @@ -196,13 +194,8 @@ QQmlBind::~QQmlBind() } \endcode - When the binding becomes inactive again, any direct bindings that were previously - set on the property will be restored. - - \note By default, a previously set literal value is not restored when the Binding becomes - inactive. Rather, the last value set by the now inactive Binding is retained. You can customize - the restoration behavior for literal values as well as bindings using the \l restoreMode - property. The default will change in Qt 6.0. + By default, any binding or value that was set perviously is restored when the binding becomes + inactive. You can customize the restoration behavior using the \l restoreMode property. \sa restoreMode */ @@ -371,8 +364,7 @@ void QQmlBind::setDelayed(bool delayed) \li Binding.RestoreBindingOrValue The original value is always restored. \endlist - \warning The default value is Binding.RestoreBinding. This will change in - Qt 6.0 to Binding.RestoreBindingOrValue. + The default value is \c 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 @@ -395,7 +387,6 @@ QQmlBind::RestorationMode QQmlBind::restoreMode() const void QQmlBind::setRestoreMode(RestorationMode newMode) { Q_D(QQmlBind); - d->restoreModeExplicit = true; if (newMode != restoreMode()) { d->restoreValue = (newMode & RestoreValue); d->restoreBinding = (newMode & RestoreBinding); @@ -482,23 +473,11 @@ 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 < 6.0 the default is Binding.RestoreBinding." - << "In Qt >= 6.0 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 < 6.0 the default is Binding.RestoreBinding." - << "In Qt >= 6.0 the default is Binding.RestoreBindingOrValue."; } } return; -- cgit v1.2.3