Go to file
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
.github/workflows GitHub Actions: Fix workflow file 2020-09-11 13:37:48 +02:00
bin CMake: Strip binaries and libraries upon installation 2020-09-30 16:16:00 +02:00
cmake CMake: use HostInfo when QT_HOST_PATH is set 2020-09-30 07:27:11 +03:00
coin Read test specific configure arguments from environment 2020-09-28 05:28:22 +00:00
config.tests CMake: Skip regeneration of manual compile test project 2020-04-09 11:26:46 +02:00
dist Remove last remainings of Qt Quick 1 imports 2020-05-25 11:48:12 +02:00
doc Doc: Remove unused porting guide document 2020-09-16 18:32:05 +02:00
examples Stylesheet example: Get rid of auto-connection slots 2020-09-25 18:04:06 +03:00
lib
mkspecs Android: add qmlimportscanner and rcc paths to deployment-settings.json 2020-09-23 14:59:07 +00:00
qmake Android: set default API level to 23 in docs 2020-09-23 17:59:07 +03:00
src Deal with {und,ov}erflow issues in QLine's length handling 2020-09-30 16:26:49 +02:00
tests Deal with {und,ov}erflow issues in QLine's length handling 2020-09-30 16:26:49 +02:00
util CMake: Rename internal functions to contain qt_internal 2020-09-23 16:59:05 +02:00
.cmake.conf pro2cmake.py: Generate .cmake.conf files for versioning 2020-04-30 17:44:03 +00:00
.gitattributes
.gitignore .gitignore: Qt Creator files cleanup 2020-09-25 07:50:15 +02:00
.lgtm.yml Skip LGTM analysis for the bootstrap library and tools 2020-07-16 01:04:34 +02:00
.prev_qt_cmdline.cmake CMake: Regenerate configure.cmake files 2020-09-28 15:48:17 +02:00
.qmake.conf Bump version 2020-02-02 13:41:14 +01:00
.tag
CMakeLists.txt CMake: Disable usage of CMake API compatibility wrappers 2020-09-23 16:59:06 +02:00
config_help.txt CMake Build: Add support for -qtlibinfix configure parameter 2020-09-23 17:31:13 +02:00
configure CMake: Fix configure -redo for top-level builds 2020-09-22 22:20:43 +02:00
configure.bat CMake: Fix configure -redo for top-level builds 2020-09-22 22:20:43 +02:00
configure.cmake By default don't try to use pkg-config when targeting Android 2020-09-28 15:48:17 +02:00
configure.json By default don't try to use pkg-config when targeting Android 2020-09-28 15:48:17 +02:00
configure.pri Android: allow setting javac build version from the configure script 2020-09-16 20:55:08 +03:00
dependencies.yaml Re-add dependencies.yaml so repos outside qt5 can be built with Coin 2019-09-19 17:07:36 +00:00
INSTALL INSTALL: Remove outdated reference to Windows CE 2019-02-13 13:01:57 +00:00
LICENSE.FDL
LICENSE.GPL2 Add new license header templates and license files 2016-01-14 20:43:46 +00:00
LICENSE.GPL3 Add new license header templates and license files 2016-01-14 20:43:46 +00:00
LICENSE.GPL3-EXCEPT Add new license header templates and license files 2016-01-14 20:43:46 +00:00
LICENSE.LGPL3 Add new license header templates and license files 2016-01-14 20:43:46 +00:00
LICENSE.LGPLv3 Remove LICENSE.GPLv3, LICENSE.LGPLv21, LGPL_EXCEPTION.txt 2018-04-16 11:02:14 +00:00
LICENSE.QT-LICENSE-AGREEMENT Update enterprise license agreement v4.2.1 2019-12-18 13:07:19 +02:00
qt_cmdline.cmake CMake: Regenerate configure.cmake files 2020-09-28 15:48:17 +02:00
qtbase.pro Update qmake before building src 2020-08-19 18:25:51 +02:00
sync.profile Remove last remaining bits of QtPlatformHeaders 2020-08-04 07:12:32 +02:00