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/qmargins.h | |
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/qmargins.h')
-rw-r--r-- | src/corelib/tools/qmargins.h | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/corelib/tools/qmargins.h b/src/corelib/tools/qmargins.h index d947e2da8e..cf40b89ee0 100644 --- a/src/corelib/tools/qmargins.h +++ b/src/corelib/tools/qmargins.h @@ -311,10 +311,10 @@ public: constexpr qreal right() const noexcept; constexpr qreal bottom() const noexcept; - constexpr void setLeft(qreal left) noexcept; - constexpr void setTop(qreal top) noexcept; - constexpr void setRight(qreal right) noexcept; - constexpr void setBottom(qreal bottom) noexcept; + constexpr void setLeft(qreal aleft) noexcept; + constexpr void setTop(qreal atop) noexcept; + constexpr void setRight(qreal aright) noexcept; + constexpr void setBottom(qreal abottom) noexcept; constexpr QMarginsF &operator+=(const QMarginsF &margins) noexcept; constexpr QMarginsF &operator-=(const QMarginsF &margins) noexcept; @@ -457,6 +457,7 @@ constexpr inline QMarginsF operator*(qreal lhs, const QMarginsF &rhs) noexcept constexpr inline QMarginsF operator/(const QMarginsF &lhs, qreal divisor) { + Q_ASSERT(divisor < 0 || divisor > 0); return QMarginsF(lhs.left() / divisor, lhs.top() / divisor, lhs.right() / divisor, lhs.bottom() / divisor); } |