qt5base-lts/tests/auto/corelib/tools
Edward Welbourne 1c591fd924 Deal with {und,ov}erflow issues in QLine's length handling
Use std::hypot() instead of sqrt() of a sum of squares.
This ensures length() can't be zero when isNull() is false.
Use length() in QLine::setLength() rather than duplicating that.

Clarify and expand some documentation; isNull() never said what
constituted validity, nor did unitVector() mention that is should not
be used on a line for which isNull() is true. Make clear that lines of
denormal length cannot be rescaled accurately.

Given that we use fuzzy comparison to determine equality of
end-points, isNull() can be false for a line with displacements less
than sqrt(numeric_limits<qreal>::denorm_min()) between the coordinates
of its end-points (as long as these are not much bigger); squaring
these would give zero, hence a zero length, where using hypot() avoids
the underflow and gives a non-zero length. Having a zero length for a
line with isNull() false would lead to problems in setLength(), which
uses an isNull() pre-test, protecting a call to unitVector().

(It was already possible for a null line to have non-zero length; this
now arises in more cases.)

Restored QLine::setLength() to the form it had before a recent change
to avoid division by zero (which resulted from underflow in computing
the length of a non-null line) but allow for the possibility that the
unit vector it computes as transient may not have length exactly one.

Add tests against {ov,und}erflow problems in QLine. Reworked the test
added during the divide-by-zero fix to make it part of the existing
test.

Pick-to: 5.15 5.12
Change-Id: I7b71d66b872ccc08a64e941acd36b45b0ea15fab
Reviewed-by: Sze Howe Koh <szehowe.koh@gmail.com>
2020-09-30 16:26:49 +02:00
..
collections CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
containerapisymmetry CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qalgorithms CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qarraydata QList: don't detach on squeeze when holding raw data 2020-09-30 10:11:00 +02:00
qbitarray CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qcache CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qcommandlineparser CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qcontiguouscache CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qcryptographichash CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qeasingcurve CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qexplicitlyshareddatapointer CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qflatmap CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qfreelist CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qhash CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qhashfunctions CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qline Deal with {und,ov}erflow issues in QLine's length handling 2020-09-30 16:26:49 +02:00
qlist QList: don't detach on squeeze when holding raw data 2020-09-30 10:11:00 +02:00
qmacautoreleasepool CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qmakearray CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qmap CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qmargins CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qmessageauthenticationcode CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qoffsetstringarray CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qpair CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qpoint CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qpointf CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qqueue CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qrect CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qringbuffer CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qscopedpointer CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qscopedvaluerollback CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qscopeguard Replace Q_REQUIRED_RESULT with [[nodiscard]] 2020-09-25 07:10:45 +02:00
qset CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qsharedpointer Rename QLibraryInfo::location() to path() 2020-09-12 23:35:56 +02:00
qsize CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qsizef CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qstl CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qtaggedpointer CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qtimeline CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qvarlengtharray CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
qversionnumber CMake: Regenerate projects to use new qt_internal_ API 2020-09-23 16:59:06 +02:00
.prev_CMakeLists.txt CMake: Regenerate subdir test projects 2020-07-09 09:38:39 +02:00
CMakeLists.txt Move implementation of QVector/List back to qlist.h 2020-06-20 20:01:33 +02:00
tools.pro Move implementation of QVector/List back to qlist.h 2020-06-20 20:01:33 +02:00