summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qpaintengineex.cpp
diff options
context:
space:
mode:
authorEirik Aavitsland <eirik.aavitsland@qt.io>2021-07-30 13:03:49 +0200
committerEirik Aavitsland <eirik.aavitsland@qt.io>2021-08-10 12:00:13 +0200
commit84aba80944a2e1c3058d7a1372e0e66676411884 (patch)
tree3f4b0815cf3a7f9df07678142ec242bd9a68b0c3 /src/gui/painting/qpaintengineex.cpp
parentaa25e8d87e1392459fc5de511798356cb5b5f7cb (diff)
Refix for avoiding huge number of tiny dashes
Previous fix hit too widely so some valid horizontal and vertical lines were affected; the root problem being that such lines have an empty control point rect (width or height is 0). Fix by caculating in the pen width. Pick-to: 6.2 6.1 5.15 Change-Id: I7a436e873f6d485028f6759d0e2c6456f07eebdc Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/gui/painting/qpaintengineex.cpp')
-rw-r--r--src/gui/painting/qpaintengineex.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp
index 22e9a621c3..d85c2a951c 100644
--- a/src/gui/painting/qpaintengineex.cpp
+++ b/src/gui/painting/qpaintengineex.cpp
@@ -415,18 +415,18 @@ void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &inPen)
clipRect = xf.inverted().mapRect(QRectF(d->exDeviceRect));
}
// Check to avoid generating unwieldy amount of dashes that will not be visible anyway
- QRectF extentRect = cpRect & clipRect;
+ qreal pw = pen.widthF() ? pen.widthF() : 1;
+ QRectF extentRect = cpRect.adjusted(-pw, -pw, pw, pw) & clipRect;
qreal extent = qMax(extentRect.width(), extentRect.height());
qreal patternLength = 0;
const QList<qreal> pattern = pen.dashPattern();
const int patternSize = qMin(pattern.size(), 32);
for (int i = 0; i < patternSize; i++)
patternLength += qMax(pattern.at(i), qreal(0));
- if (pen.widthF())
- patternLength *= pen.widthF();
+ patternLength *= pw;
if (qFuzzyIsNull(patternLength)) {
pen.setStyle(Qt::NoPen);
- } else if (qFuzzyIsNull(extent) || extent / patternLength > 10000) {
+ } else if (extent / patternLength > 10000) {
// approximate stream of tiny dashes with semi-transparent solid line
pen.setStyle(Qt::SolidLine);
QColor color(pen.color());