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/qline.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/qline.h')
-rw-r--r-- | src/corelib/tools/qline.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/corelib/tools/qline.h b/src/corelib/tools/qline.h index 9b544f2e7e..426d69cd6d 100644 --- a/src/corelib/tools/qline.h +++ b/src/corelib/tools/qline.h @@ -372,7 +372,9 @@ constexpr inline QPointF QLineF::center() const inline void QLineF::setLength(qreal len) { + Q_ASSERT(qIsFinite(len)); const qreal oldLength = length(); + Q_ASSERT(qIsFinite(oldLength)); // Scale len by dx() / length() and dy() / length(), two O(1) quantities, // rather than scaling dx() and dy() by len / length(), which might overflow. if (oldLength > 0) |