Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-116634

Add functionality to help to identify causes of polish loops

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • P2: Important
    • None
    • None
    • Quick: Layouts
    • 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

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              smd Jan Arve
              smd Jan Arve
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes