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

QRect::intersects() returns false for very large rectangles

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 4.8.1
    • Core: Other
    • None
    • Ubuntu 10.4
    • 46e6bbd22991dd62040ee1eb24433b5f7316793a

    Description

      In QRect::operator& INT_MAX is exceeded if very large rectangles are used. In QRect::operator&() x2-x1 overflows the INT_MAX.

      The code snippet below can be used to reproduce the issue:

      #include <QDebug>
      #include <QRect>
      #include <QPoint>
      
      int main(int argc, char *argv[])
      {
        QRect r1(QPoint(-2000000000, 2000000000), QPoint(2000000000, -2000000000));
      
        QRect r2(QPoint(0, 100), QPoint(100, 0));
        bool isec = r1.intersects(r2);
        QRect rIsec = r1 & r2;
        qDebug() << "Intersection:" << isec << rIsec.left() << rIsec.y() + rIsec.height() << rIsec.x() + rIsec.width() << rIsec.top();
        qDebug() << rIsec.isNull();
        qDebug() << rIsec;
        return 0;
      }
      

      Attachments

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

        Activity

          People

            qtcomsupport Qt Support
            qtcomsupport Qt Support
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes