aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickitem.cpp
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2023-09-06 17:18:42 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2023-09-10 09:58:07 +0200
commit8c7c60fff37ea7bb7420d925e2f88e62764bf86b (patch)
tree2d30c99a90f1e59a4acf1893e7e0986afe87c763 /src/quick/items/qquickitem.cpp
parent15c32e3952d21198a04248659aa489746634ac65 (diff)
Loader: re-set ItemObservesViewport flag on child if already set
When QQuickLoaderPrivate::load() loads a Text item, its ctor calls QQuickTextPrivate::init(), which calls setFlag(ItemObservesViewport). QQuickItem::setFlag() tries to go up the parent hierarchy to get subtreeTransformChangedEnabled turned on; but at that time, the Text does not yet have a parent. If a Flickable contains a Loader that loads a Text with large content, QQuickTextPrivate::transformChanged() needs to get called during scrolling. Loader is not interested in these notifications for itself; so its parent's QQuickItemPrivate::transformChanged() detects that and turns off subtreeTransformChangedEnabled. After the child is loaded, QQuickLoader::itemChange() detects that the child's ItemObservesViewport is already set, and sets the same flag again. setFlag() doesn't have a guard, so the parent traversal happens again, and subtreeTransformChangedEnabled gets turned back on. If a different child were loaded, and that child did not want the notifications, the next QQuickItemPrivate::transformChanged() would detect it. If the child changed its own flag later on (e.g. because a small amount of text was replaced with a larger document, exceeding QQUICKTEXT_LARGETEXT_THRESHOLD), QQuickItem::setFlag() would be able to go up the parent chain at that time. For the autotest, long.qml has about 15KB of text. Maybe it will be reusable. At least it should compress well in git packfiles, since we have this license text elsewhere. Fixes: QTBUG-115687 Pick-to: 6.5 6.6 Change-Id: I87b6a42f5735b8f9c2267f91a4112681da05de5d Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
Diffstat (limited to 'src/quick/items/qquickitem.cpp')
-rw-r--r--src/quick/items/qquickitem.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index 8eaf064f23..62e3c02a65 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -6970,6 +6970,8 @@ void QQuickItem::setFlag(Flag flag, bool enabled)
else
setFlags((Flags)(d->flags & ~(quint32)flag));
+ // We don't return early if the flag did not change. That's useful in case
+ // we need to intentionally trigger this parent-chain traversal again.
if (enabled && flag == ItemObservesViewport) {
QQuickItem *par = parentItem();
while (par) {