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

QRectF::operator==() and QPointF::operator==() disagree for sufficiently high x/y coordinates

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P3: Somewhat important P3: Somewhat important
    • 5.11.1
    • 5.6.2, 5.7.1, 5.8.0, 5.9.1
    • Core: Other
    • None
    • x86/x64 machine (with qreal == double) for the test program

      QRectF::operator==() uses qFuzzyCompare(), while QPointF::operator==() uses qFuzzyIsNull(), but the two methods yield different comparison results for sufficiently high floating point values (but as low as 200.0, see attached test program)

      This creates interesting situations where 

      rect1 == rect2 && rect1.topLeft() != rect2.topLeft()

       

       

      See attached test program, which shows exactly where things start breaking (at least on a machine with sizeof(qreal)==sizeof(double)).

       

      I would have provided a change request with a fix to switch QPointF::operator==() to use qFuzzyCompare, but I'm not 100% sure this is the right fix. Maybe qFuzzyIsNull() itself needs to be fixed instead, or something else. So I'm opening this issue first for feedback on the preferred fix, then I'll be happy to provide a change request with the fix if needed.

        1. equaltest.pro
          0.1 kB
          Romain Pokrzywka
        2. main.cpp
          1 kB
          Romain Pokrzywka
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            allan.jensen Allan Sandfeld Jensen
            kromain Romain Pokrzywka
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes