diff options
author | Eirik Aavitsland <eirik.aavitsland@qt.io> | 2021-08-17 13:50:50 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-08-24 09:37:21 +0000 |
commit | 97a96c26dd5c1153335273d096114fd39fa59363 (patch) | |
tree | e8950c4aa29b412f4faf127dd53d64de15edb89f /src/gui/painting/qpaintengine_raster.cpp | |
parent | 52743057d4f462c3a8edfc9597f3ad6194d5a357 (diff) |
QDashStroker: cap the number of repetitions of the pattern
Since the dashing is computed even outside the clipping and device
area, painting very long dashed lines could consume unexpected amounts
of time and resources. Fix by placing a limit on the dashing, and fall
back to solid line drawing if hit.
Fixes: QTBUG-95594
Change-Id: Ida05ecd8fe6df402c9e669206fd5cec4a9f5386a
Reviewed-by: Robert Löhning <robert.loehning@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
(cherry picked from commit 279a434c1c8689f00b1ab8ed571f8732a803a7eb)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/gui/painting/qpaintengine_raster.cpp')
-rw-r--r-- | src/gui/painting/qpaintengine_raster.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 90f4e048ed..e3444e6229 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -3261,6 +3261,11 @@ void QRasterPaintEnginePrivate::rasterizeLine_dashed(QLineF line, qreal length = line.length(); Q_ASSERT(length > 0); + if (length / (patternLength * width) > QDashStroker::repetitionLimit()) { + rasterizer->rasterizeLine(line.p1(), line.p2(), width / length, squareCap); + return; + } + while (length > 0) { const bool rasterize = *inDash; qreal dash = (pattern.at(*dashIndex) - *dashOffset) * width; |