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.
|For Gerrit Dashboard: QTBUG-87174|
|316356,6||Fix a bug in the initialization (and debug-output) of BSP trees||dev||qt/qtbase||Status: MERGED||+2||0|
|316373,2||Fix a bug in the initialization (and debug-output) of BSP trees||5.15||qt/qtbase||Status: MERGED||+2||0|