Skip to content

Commit

Permalink
Workaround a qt issue which causes unpredictable dash patterns at
Browse files Browse the repository at this point in the history
very narrow pen sizes

Force the pen width to a minimum 1 px size when the advanced dash
tweaks are enabled to avoid this
  • Loading branch information
nyalldawson committed Aug 7, 2020
1 parent 51bd48f commit 0f14362
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/core/symbology/qgslinesymbollayer.cpp
Expand Up @@ -349,7 +349,6 @@ void QgsSimpleLineSymbolLayer::renderPolyline( const QPolygonF &points, QgsSymbo
}

const bool applyPatternTweaks = mAlignDashPattern
&& pen.widthF() > 1.0
&& ( pen.style() != Qt::SolidLine || !pen.dashPattern().empty() )
&& pen.dashOffset() == 0;

Expand Down Expand Up @@ -639,10 +638,13 @@ void QgsSimpleLineSymbolLayer::drawPathWithDashPatternTweaks( QPainter *painter,
return;

QVector< qreal > sourcePattern = pen.dashPattern();
const double dashWidthDiv = std::max( 1.0, pen.widthF() );
const double dashWidthDiv = std::max( 1.0001, pen.widthF() );
// back to painter units
for ( int i = 0; i < sourcePattern.size(); ++ i )
sourcePattern[i] *= dashWidthDiv;
sourcePattern[i] *= pen.widthF();

if ( pen.widthF() <= 1.0 )
pen.setWidthF( 1.0001 );

QVector< qreal > buffer;
QPolygonF bufferedPoints;
Expand Down

0 comments on commit 0f14362

Please sign in to comment.