Skip to content
Permalink
Browse files

Workaround odd upstream Qt issue where a painter with a semi-transparent

brush with no solid pattern incorrectly applies the brush opacity to
the pen when exporting to printer devices

Fixes #36580

(cherry picked from commit 38c8218)
  • Loading branch information
nyalldawson committed Jun 19, 2020
1 parent 5a3ae72 commit a36a19112ba9a9fe9f0e08af15368b233fd4e4c6
Showing with 27 additions and 4 deletions.
  1. +27 −4 src/core/symbology/qgsfillsymbollayer.cpp
@@ -38,6 +38,10 @@
#include <QDomDocument>
#include <QDomElement>

#ifndef QT_NO_PRINTER
#include <QPrinter>
#endif

QgsSimpleFillSymbolLayer::QgsSimpleFillSymbolLayer( const QColor &color, Qt::BrushStyle style, const QColor &strokeColor, Qt::PenStyle strokeStyle, double strokeWidth,
Qt::PenJoinStyle penJoinStyle )
: mBrushStyle( style )
@@ -271,9 +275,6 @@ void QgsSimpleFillSymbolLayer::renderPolygon( const QPolygonF &points, QList<QPo

applyDataDefinedSymbology( context, mBrush, mPen, mSelPen );

p->setBrush( context.selected() ? mSelBrush : mBrush );
p->setPen( context.selected() ? mSelPen : mPen );

QPointF offset;
if ( !mOffset.isNull() )
{
@@ -282,7 +283,29 @@ void QgsSimpleFillSymbolLayer::renderPolygon( const QPolygonF &points, QList<QPo
p->translate( offset );
}

_renderPolygon( p, points, rings, context );
#ifndef QT_NO_PRINTER
if ( mBrush.style() == Qt::SolidPattern || mBrush.style() == Qt::NoBrush || !dynamic_cast<QPrinter *>( p->device() ) )
#endif
{
p->setPen( context.selected() ? mSelPen : mPen );
p->setBrush( context.selected() ? mSelBrush : mBrush );
_renderPolygon( p, points, rings, context );
}
#ifndef QT_NO_PRINTER
else
{
// workaround upstream issue https://github.com/qgis/QGIS/issues/36580
// when a non-solid brush is set with opacity, the opacity incorrectly applies to the pen
// when exporting to PDF/print devices
p->setBrush( context.selected() ? mSelBrush : mBrush );
p->setPen( Qt::NoPen );
_renderPolygon( p, points, rings, context );

p->setPen( context.selected() ? mSelPen : mPen );
p->setBrush( Qt::NoBrush );
_renderPolygon( p, points, rings, context );
}
#endif

if ( !mOffset.isNull() )
{

0 comments on commit a36a191

Please sign in to comment.
You can’t perform that action at this time.