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

Wrong painting of scene items with relative x-/y-positions exceeding INT_MAX

    XMLWordPrintable

Details

    Description

      We are using a large scene with dimensions exceeding INT_MAX in our application. To have no integer overflow in the view (e.g. in the scrollbar ticks) the scene rect of the view is restricted to show only parts of the scene. Unfortunately items far outside the scene rect of the view get paint calls due to an integer overflow in QGraphicsScenePrivate::drawSubtreeRecursive(). The problematic code is:

      if (drawItem) {
           QRect viewBoundingRect = preciseViewBoundingRect.toAlignedRect();
           viewBoundingRect.adjust(-int(rectAdjust), -int(rectAdjust), rectAdjust, rectAdjust);
           if (widget)
               item->d_ptr->paintedViewBoundingRects.insert(widget, viewBoundingRect);
           drawItem = exposedRegion ? exposedRegion->intersects(viewBoundingRect)
                                    : !viewBoundingRect.normalized().isEmpty();
           itemIsOutsideVisibleRect = !drawItem;
       }
      

      Here the transformed bounding rect of the item (preciseViewBoundingRect (QRectF)) is assigned to an integer rect (viewBoundingRect). If now the position of the preciseViewBoundingRect exceeds INT_MAX the result of the assignment is undefined and the subsequent test for an overlap with the exposed region may return true even if the original bounding rect is outside the visible range.

      A simple solution of this bug would be to clip the preciseViewBoundingRect beforehand so that the resulting clipped bounding rect fits into an integer QRect.

      Note, that this bug is related to QTBUG-21786. However, in our case not the dimension of the bounding rect exceeds INT_MAX but the position.

      Attachments

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

        Activity

          People

            sletta Gunnar Sletta
            soeren Sören Henning
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes