diff options
author | Eirik Aavitsland <eirik.aavitsland@qt.io> | 2019-05-02 11:37:26 +0200 |
---|---|---|
committer | Eirik Aavitsland <eirik.aavitsland@qt.io> | 2019-05-08 12:34:19 +0000 |
commit | 95fa35fc72c2fe199c4c6a891cfa68ed17c4aa71 (patch) | |
tree | e53a149a56923faea5b540cf54a269329ffe8d8e /src/gui/painting/qbezier.cpp | |
parent | 19d13f8b2d966b09547a975e81f6f99f956df608 (diff) |
Fix possible endless loop when stroking curves
The bezier shifting algorithm compared coordinates exactly, and so
could end up in an endless loop when values were at the edge of the
number resolution. Fix by using fuzzy comparison instead.
Fixes: QTBUG-75522
Change-Id: I61346edbd87389f66965a906ac337fc1f5300e5c
Reviewed-by: Robert Loehning <robert.loehning@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/gui/painting/qbezier.cpp')
-rw-r--r-- | src/gui/painting/qbezier.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/gui/painting/qbezier.cpp b/src/gui/painting/qbezier.cpp index ddd1d997f2..8cda4b4072 100644 --- a/src/gui/painting/qbezier.cpp +++ b/src/gui/painting/qbezier.cpp @@ -261,9 +261,9 @@ static ShiftResult good_offset(const QBezier *b1, const QBezier *b2, qreal offse static ShiftResult shift(const QBezier *orig, QBezier *shifted, qreal offset, qreal threshold) { int map[4]; - bool p1_p2_equal = (orig->x1 == orig->x2 && orig->y1 == orig->y2); - bool p2_p3_equal = (orig->x2 == orig->x3 && orig->y2 == orig->y3); - bool p3_p4_equal = (orig->x3 == orig->x4 && orig->y3 == orig->y4); + bool p1_p2_equal = qFuzzyCompare(orig->x1, orig->x2) && qFuzzyCompare(orig->y1, orig->y2); + bool p2_p3_equal = qFuzzyCompare(orig->x2, orig->x3) && qFuzzyCompare(orig->y2, orig->y3); + bool p3_p4_equal = qFuzzyCompare(orig->x3, orig->x4) && qFuzzyCompare(orig->y3, orig->y4); QPointF points[4]; int np = 0; |