QQuickItem: more fixes for bindable properties

A more detailed look revealed some more places where the properties
were incorrectly accessed from the setters.
Use the usual (set)ValueBypassingBindings() approach to fix it.

The exceptions from the usual property handling are the setSize()
and setPosition() setters. The first one is documented to not
remove the binding, and the second one has a comment stating the
same. So, do not call removeBindingUnlessInWrapper() in these
setters.

This commit amends f85de75735

Task-number: QTBUG-117899
Pick-to: 6.6 6.5
Change-Id: I97a94cbf2b38c57e9a260e54c9894c2ffd47271d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
Ivan Solovev 2023-10-16 15:58:54 +02:00
parent 53b9c17749
commit e8c8ddeb94
1 changed files with 15 additions and 11 deletions

View File

@ -7117,11 +7117,12 @@ void QQuickItem::setY(qreal v)
void QQuickItem::setPosition(const QPointF &pos)
{
Q_D(QQuickItem);
if (QPointF(d->x, d->y) == pos)
return;
const qreal oldx = d->x;
const qreal oldy = d->y;
const qreal oldx = d->x.valueBypassingBindings();
const qreal oldy = d->y.valueBypassingBindings();
if (QPointF(oldx, oldy) == pos)
return;
/* This preserves the bindings, because that was what the code used to do
The effect of this is that you can have
@ -7141,7 +7142,8 @@ void QQuickItem::setPosition(const QPointF &pos)
d->dirty(QQuickItemPrivate::Position);
const qreal w = d->width, h = d->height;
const qreal w = d->width.valueBypassingBindings();
const qreal h = d->height.valueBypassingBindings();
geometryChange(QRectF(pos.x(), pos.y(), w, h), QRectF(oldx, oldy, w, h));
}
@ -7499,11 +7501,11 @@ void QQuickItem::setImplicitSize(qreal w, qreal h)
const qreal oldHeight = height;
if (!wDone) {
width = w;
d->width = w;
d->width.setValueBypassingBindings(w);
}
if (!hDone) {
height = h;
d->height = h;
d->height.setValueBypassingBindings(h);
}
d->dirty(QQuickItemPrivate::Size);
@ -7559,17 +7561,19 @@ void QQuickItem::setSize(const QSizeF &size)
d->heightValidFlag = true;
d->widthValidFlag = true;
if (d->width == size.width() && d->height == size.height())
const qreal oldHeight = d->height.valueBypassingBindings();
const qreal oldWidth = d->width.valueBypassingBindings();
if (oldWidth == size.width() && oldHeight == size.height())
return;
const qreal oldHeight = d->height;
const qreal oldWidth = d->width;
d->height.setValueBypassingBindings(size.height());
d->width.setValueBypassingBindings(size.width());
d->dirty(QQuickItemPrivate::Size);
const qreal x = d->x, y = d->y;
const qreal x = d->x.valueBypassingBindings();
const qreal y = d->y.valueBypassingBindings();
geometryChange(QRectF(x, y, size.width(), size.height()), QRectF(x, y, oldWidth, oldHeight));
}