diff options
author | Ivan Solovev <ivan.solovev@qt.io> | 2023-09-18 15:16:12 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-09-20 00:40:24 +0000 |
commit | 39755a5e65642403dde3bdf5b63dab8b23d98874 (patch) | |
tree | dbc4c340eaa395490e1b694f35e6978774ff3995 | |
parent | 131c976b873a80aa3babe0d0c7fbb36c7a252cbf (diff) |
QQuickItem: fix binding loops for x, y, width, and height
Use {set}ValueBypassingBinding() to read and write the value of the
property.
Use valueBypassingBinding() to get the values of other realted
properties before calling geometryChanged().
The tests for these bindable properties already exist. They will detect
the binding loops as soon as the related qtbase patch is merged.
Fixes: QTBUG-116540
Change-Id: Ifb6caac2d5176fa6985a170fcdfe0dceeac10936
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
(cherry picked from commit f85de757355889f534e9e5e858547874eb377ec5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit b3b9987ebd2f0d17f755228e06faddd2a67525b0)
-rw-r--r-- | src/quick/items/qquickitem.cpp | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index a2e8c989d1..30bbf505da 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -7068,15 +7068,17 @@ void QQuickItem::setX(qreal v) if (qt_is_nan(v)) return; - const qreal oldx = d->x; + const qreal oldx = d->x.valueBypassingBindings(); if (oldx == v) return; - d->x = v; + d->x.setValueBypassingBindings(v); d->dirty(QQuickItemPrivate::Position); - const qreal y = d->y, w = d->width, h = d->height; + const qreal y = d->y.valueBypassingBindings(); + const qreal w = d->width.valueBypassingBindings(); + const qreal h = d->height.valueBypassingBindings(); geometryChange(QRectF(v, y, w, h), QRectF(oldx, y, w, h)); } @@ -7087,17 +7089,19 @@ void QQuickItem::setY(qreal v) if (qt_is_nan(v)) return; - const qreal oldy = d->y; + const qreal oldy = d->y.valueBypassingBindings(); if (oldy == v) return; - d->y = v; + d->y.setValueBypassingBindings(v); d->dirty(QQuickItemPrivate::Position); // we use v instead of d->y, as that avoid a method call // and we have v anyway in scope - const qreal x = d->x, w = d->width, h = d->height; + const qreal x = d->x.valueBypassingBindings(); + const qreal w = d->width.valueBypassingBindings(); + const qreal h = d->height.valueBypassingBindings(); geometryChange(QRectF(x, v, w, h), QRectF(x, oldy, w, h)); } @@ -7167,15 +7171,17 @@ void QQuickItem::setWidth(qreal w) return; d->widthValidFlag = true; - const qreal oldWidth = d->width; + const qreal oldWidth = d->width.valueBypassingBindings(); if (oldWidth == w) return; - d->width = w; + d->width.setValueBypassingBindings(w); d->dirty(QQuickItemPrivate::Size); - const qreal x = d->x, y = d->y, h = d->height; + const qreal x = d->x.valueBypassingBindings(); + const qreal y = d->y.valueBypassingBindings(); + const qreal h = d->height.valueBypassingBindings(); geometryChange(QRectF(x, y, w, h), QRectF(x, y, oldWidth, h)); } @@ -7373,15 +7379,17 @@ void QQuickItem::setHeight(qreal h) return; d->heightValidFlag = true; - const qreal oldHeight = d->height; + const qreal oldHeight = d->height.valueBypassingBindings(); if (oldHeight == h) return; - d->height = h; + d->height.setValueBypassingBindings(h); d->dirty(QQuickItemPrivate::Size); - const qreal x = d->x, y = d->y, w = d->width; + const qreal x = d->x.valueBypassingBindings(); + const qreal y = d->y.valueBypassingBindings(); + const qreal w = d->width.valueBypassingBindings(); geometryChange(QRectF(x, y, w, h), QRectF(x, y, w, oldHeight)); } |