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 <fabian.kosmale@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
Ulf Hermann 2019-10-09 10:54:15 +02:00
parent 40321e482b
commit 62e3c74080
1 changed files with 4 additions and 25 deletions

View File

@ -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;