From 6eba6dd95082d5087662f9755d2f01ecb741ddc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 27 Nov 2023 18:50:31 +0100 Subject: QQuickItem: Call markSortedChildrenDirty before QQuickItemPrivate::dirty() Marking an item dirty will normally result in adding the item to the dirty list, and telling the window about it, via QQuickWindowPrivate's dirtyItem(), which in turn does QQuickWindow::maybeUpdate(). This results in an asynchronous update, where we then render the scene graph, including updating its paint nodes. But QQuickItemPrivate::dirty() may also involve synchronous actions, such as calling QQuickItemPrivate::transformChanged(). To be on the safe side, we markSortedChildrenDirty before dirtying, so that any synchronous logic that runs as part of the dirtying will observe the newly dirtied sorted children. We were already doing this for QQuickItemPrivate::ChildrenChanged, but not for QQuickItemPrivate::ChildrenStackingChanged. Change-Id: I47f0ee81e17ed766ead7c7644596e90d240482a2 Reviewed-by: Volker Hilsheimer Reviewed-by: Shawn Rutledge --- src/quick/items/qquickitem.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/quick/items/qquickitem.cpp') diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 45179bca52..8b1188e4d4 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -2803,8 +2803,8 @@ void QQuickItem::stackBefore(const QQuickItem *sibling) parentPrivate->childItems.move(myIndex, myIndex < siblingIndex ? siblingIndex - 1 : siblingIndex); - parentPrivate->dirty(QQuickItemPrivate::ChildrenStackingChanged); parentPrivate->markSortedChildrenDirty(this); + parentPrivate->dirty(QQuickItemPrivate::ChildrenStackingChanged); for (int ii = qMin(siblingIndex, myIndex); ii < parentPrivate->childItems.size(); ++ii) QQuickItemPrivate::get(parentPrivate->childItems.at(ii))->siblingOrderChanged(); @@ -2848,8 +2848,8 @@ void QQuickItem::stackAfter(const QQuickItem *sibling) parentPrivate->childItems.move(myIndex, myIndex > siblingIndex ? siblingIndex + 1 : siblingIndex); - parentPrivate->dirty(QQuickItemPrivate::ChildrenStackingChanged); parentPrivate->markSortedChildrenDirty(this); + parentPrivate->dirty(QQuickItemPrivate::ChildrenStackingChanged); for (int ii = qMin(myIndex, siblingIndex + 1); ii < parentPrivate->childItems.size(); ++ii) QQuickItemPrivate::get(parentPrivate->childItems.at(ii))->siblingOrderChanged(); @@ -6002,8 +6002,8 @@ void QQuickItem::setZ(qreal v) d->dirty(QQuickItemPrivate::ZValue); if (d->parentItem) { - QQuickItemPrivate::get(d->parentItem)->dirty(QQuickItemPrivate::ChildrenStackingChanged); QQuickItemPrivate::get(d->parentItem)->markSortedChildrenDirty(this); + QQuickItemPrivate::get(d->parentItem)->dirty(QQuickItemPrivate::ChildrenStackingChanged); } emit zChanged(); -- cgit v1.2.3