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

Inconsistent and wrong usage of qIsNull(double/float) function

    XMLWordPrintable

Details

    • I767e5280bd26614e8e78ae62b274eb9bc4ade385

    Description

      qIsNull(double/float) does some bit checking to check if a floating point number is +0.0.

      That is not what is wanted in the cases where this function is used in QPointF, QSizeF, QQuaternion, QVector2D, QVector3D and QVector4D.

      And in QRectF for example a correct "== 0.0" is used instead (which is also true for -0.0).

      inline bool QRectF::isNull() const { return w == 0. && h == 0.; }

      which results in QRecfF(0.0, 0.0, -0.0, -0.0).isNull() being true

      While using qIsNull like in QPointF

      inline bool QPointF::isNull() const { return qIsNull(xp) && qIsNull(yp); }

      results in QPointF(-0.0, -0.0).isNull() being false

      And even worse it is used in QSizeF::scale to not divide by 0.0 which fails for -0.0 of course:

      So QSizeF(-0.0, -0.0).scale(QSizeF(1.0, 1.0), Qt::IgnoreAspectRatio) results in QSizeF(1, nan)

      Please replace qIsNull(double/float) with "== 0.0" in QPointF, QSizeF, QQuaternion, QVector2D, QVector3D and QVector4D.

      Attachments

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

        Activity

          People

            mitch_curtis Mitch Curtis
            jpetersen Jan Arne Petersen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes