diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2020-12-01 14:07:26 +0100 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2021-02-04 17:18:51 +0100 |
commit | 7a738daa97436478a21b5dd31ba2312b2cb2df41 (patch) | |
tree | 9e4a536302e2c0b212f99031bb017dfb7961effe /src/corelib/tools/qsize.cpp | |
parent | 96ef1769c18d90053e48176c22a594e03f1d6e38 (diff) |
Make explicit that we expect co-ordinates to be finite
The various spatial-vector, line, point, region and margin types have
all long taken for granted that their co-ordinates are finite and, in
particular, not NaN. Make this expectation explicit in the
documentation. Added assertions where (chiefly) noexcept and (where
the assertion would be a simple qIsFinite() call) constexpr didn't
preclude doing so. Also assert against zero divisors that would lead
to non-finite results.
Make minor clean-ups to docs in the process. QMarginsF had several
methods whose declaration, definition and docs weren't consistent in
their parameter names.
Task-number: QTBUG-89010
Change-Id: I601a830959d13a73dcb17ce31a1202a1486c8f7f
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/corelib/tools/qsize.cpp')
-rw-r--r-- | src/corelib/tools/qsize.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/corelib/tools/qsize.cpp b/src/corelib/tools/qsize.cpp index 788356002c..2779948aae 100644 --- a/src/corelib/tools/qsize.cpp +++ b/src/corelib/tools/qsize.cpp @@ -526,7 +526,7 @@ QDebug operator<<(QDebug dbg, const QSize &s) /*! \fn QSizeF::QSizeF(qreal width, qreal height) - Constructs a size with the given \a width and \a height. + Constructs a size with the given finite \a width and \a height. */ /*! @@ -550,7 +550,7 @@ QDebug operator<<(QDebug dbg, const QSize &s) /*! \fn bool QSizeF::isValid() const - Returns \c true if both the width and height is equal to or greater + Returns \c true if both the width and height are equal to or greater than 0; otherwise returns \c false. \sa isNull(), isEmpty() @@ -575,7 +575,7 @@ QDebug operator<<(QDebug dbg, const QSize &s) /*! \fn void QSizeF::setWidth(qreal width) - Sets the width to the given \a width. + Sets the width to the given finite \a width. \sa width(), rwidth(), setHeight() */ @@ -583,7 +583,7 @@ QDebug operator<<(QDebug dbg, const QSize &s) /*! \fn void QSizeF::setHeight(qreal height) - Sets the height to the given \a height. + Sets the height to the given finite \a height. \sa height(), rheight(), setWidth() */ @@ -734,7 +734,7 @@ QSizeF QSizeF::scaled(const QSizeF &s, Qt::AspectRatioMode mode) const noexcept \fn QSizeF &QSizeF::operator*=(qreal factor) \overload - Multiplies both the width and height by the given \a factor and + Multiplies both the width and height by the given finite \a factor and returns a reference to the size. \sa scale() @@ -780,7 +780,7 @@ QSizeF QSizeF::scaled(const QSizeF &s, Qt::AspectRatioMode mode) const noexcept \overload - Multiplies the given \a size by the given \a factor and returns + Multiplies the given \a size by the given finite \a factor and returns the result. \sa QSizeF::scale() @@ -791,7 +791,7 @@ QSizeF QSizeF::scaled(const QSizeF &s, Qt::AspectRatioMode mode) const noexcept \overload - Multiplies the given \a size by the given \a factor and returns + Multiplies the given \a size by the given finite \a factor and returns the result. */ @@ -800,8 +800,8 @@ QSizeF QSizeF::scaled(const QSizeF &s, Qt::AspectRatioMode mode) const noexcept \overload - Divides both the width and height by the given \a divisor and - returns a reference to the size. + Divides both the width and height by the given \a divisor and returns a + reference to the size. The \a divisor must not be either zero or NaN. \sa scale() */ @@ -812,7 +812,7 @@ QSizeF QSizeF::scaled(const QSizeF &s, Qt::AspectRatioMode mode) const noexcept \overload Divides the given \a size by the given \a divisor and returns the - result. + result. The \a divisor must not be either zero or NaN. \sa QSizeF::scale() */ |