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

Wrong initialization of the bsp tree used by QGraphicsScene

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 5.14.0
    • Fix Version/s: 5.15.2, 6.0.0
    • Component/s: Widgets: GraphicsView
    • Labels:
      None
    • Commits:
      40874625f996899ca1e976f0240da697e784c2c6 (qt/qtbase/dev) a8ad90665201218fa02b55ef2ed626c23c291036 (qt/qtbase/5.15)

      Description

      I noticed a big performance issue when using thin and long scene rectangles in a QGraphicsView/QGraphicsScene. I used dimensions like 4000x2000000 (wxh) and filled the scene with equally distributed lines along the y-axis. Whenever my viewport crossed half of the scene height, the performance of the QGraphicsScene went downhill. So i looked into the source code and noticed a bug in the initialization of the bsp tree (qgraphicsscene_bsp.cpp).

      The tree is build in the initialization function with a given depth, partitioning the given rectangle. On a "Horizontal" split the current rectangle is split along the y-axis, creating two childs with the dimensions [x, y, width, height / 2] and [x, y + height / 2, width, height / 2] respectively. When the bsp tree is initialized, the type of the root node is set to "Horizontal". However, the offset of the root node is wrongly initialized with a split along the x-axis instead of the y-axis. This leads to wrong behavior on QGraphicsScenes with a non square aspect ratio. E.g on a QGraphicsScene with an apsect ratio favoring the y-axis, every item between yItem = sceneWidth/2 and yItem = sceneHeight/2 will be added to the wrong leaf.

      I created an illustration showing the current behaviour.

        Attachments

        For Gerrit Dashboard: QTBUG-87174
        # Subject Branch Project Status CR V

          Activity

            People

            Assignee:
            bibr Andreas Aardal Hanssen
            Reporter:
            independent9100 Andreas Klots
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes