Details
-
Suggestion
-
Resolution: Unresolved
-
P2: Important
-
None
-
None
-
None
Description
Polish loops can occur with all kind of Quick Items, but layouts are probably more affected, and it can be quite hard to track down which binding is the culprit. It can be simple things such as
width: parentLayout.width
but it can also be caused by bigger cycles that involves more than two items.
We should investigate solutions that makes it easier to track down these polish loops.
Note that QQuickWindowPrivate:polishItems() already have a "polish loop detector", but the information it gives might not give a clear view on why there is a loop. It just gives the items involved, and not the specific property bindings.
Suggested improvements:
- Print the call stack when a loop is detected (unfortunately this is not available on all platforms AFAIK). Maybe we don't want to print the call stack each time this occurs, so, maybe it be enabled by e.g. an environment variable when needed.
- Can we deduce the properties involved by inspecting the call stack?
- Also, are there APIs missing that can help developers achieve the layout they want without violating the "rules of layouts"? Why do developers do these mistakes in the first place? (Well, one answer is that it is very simple to set up bindings between items in QML). For instance, if somebody wants a layout with uniform distribution of its items they might be tempted to do:
RowLayout { Button { text: "I"; implicitWidth: parent.width/4} Button { text: "want"; implicitWidth: parent.width/4} Button { text: "uniform"; implicitWidth: parent.width/4} Button { text: "distribution"; implicitWidth: parent.width/4} }
This might cause a polish loop. Therefore in Qt 6.6, we added API to help with this (RowLayout::uniformCellSize) https://codereview.qt-project.org/c/qt/qtdeclarative/+/467103/17, but there might be other cases where we can add APIs to help the developers to not "do the wrong thing".
Attachments
Issue Links
- relates to
-
QTBUG-126740 found the simplest way yet to create an infinite polish loop
- Reported
-
QTBUG-126474 QQuickLayout Recursive Rearrange Locks Application
- Closed
-
QTBUG-122782 Infinite polish loop in ColumnLayout + GridLayout since "Adapt layouts to take advantage of new size policy information"
- Closed