summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Sander <oliver.sander@tu-dresden.de>2020-03-25 21:14:34 +0100
committerAlbert Astals Cid <tsdgeos@yahoo.es>2020-03-26 21:39:28 +0000
commit5e1a83dbdc065504291528554cb11ab8fabeb5f6 (patch)
treef9729c373fa5d3653a7ab6950ea15895c21e6525
parent170aa09affc7637cdc8087bb7ae8012b37a80025 (diff)
Avoid division by zero in updateLineDash
Qt measures dash patterns in terms of line width. This means that you have to divide by the width, which doesn't work if the line width is 'cosmetic', i.e., zero. The Qt documentation states that this case should be treated as if the line width was 1 pixel. BUG: 695
-rw-r--r--qt5/src/ArthurOutputDev.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/qt5/src/ArthurOutputDev.cc b/qt5/src/ArthurOutputDev.cc
index 3ec78e06..3afe908a 100644
--- a/qt5/src/ArthurOutputDev.cc
+++ b/qt5/src/ArthurOutputDev.cc
@@ -268,10 +268,17 @@ void ArthurOutputDev::updateLineDash(GfxState *state)
}
QVector<qreal> pattern(dashLength);
+ double scaling = state->getLineWidth();
+
+ // Negative line widths are not allowed, width 0 counts as 'one pixel width'.
+ if (scaling <= 0) {
+ scaling = 1.0;
+ }
+
for (int i = 0; i < dashLength; ++i) {
// pdf measures the dash pattern in dots, but Qt uses the
// line width as the unit.
- pattern[i] = dashPattern[i] / state->getLineWidth();
+ pattern[i] = dashPattern[i] / scaling;
}
m_currentPen.setDashPattern(pattern);
m_currentPen.setDashOffset(dashStart);