Skip to content
Permalink
Browse files
[layouts] Restore forced rasterization of whole layout map item
when a layer has opacity set for Qt < 5.15

Workarounds bugs in the PDF export for these earlier versions

Fixes #42698
  • Loading branch information
nyalldawson authored and github-actions committed Jun 23, 2021
1 parent c9ad090 commit 095c0dc9c9830e8f10135a3e559078c4fd44185f
Showing with 12 additions and 0 deletions.
  1. +7 −0 src/core/qgsmapsettingsutils.cpp
  2. +5 −0 tests/src/core/testqgsmapsettingsutils.cpp
@@ -54,6 +54,13 @@ QStringList QgsMapSettingsUtils::containsAdvancedEffects( const QgsMapSettings &
// if vector layer, check labels and feature blend mode
if ( QgsVectorLayer *currentVectorLayer = qobject_cast<QgsVectorLayer *>( layer ) )
{
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
// Qt < 5.15 does not correctly support layer level opacity in PDF exports -- see https://github.com/qgis/QGIS/issues/42698
if ( !qgsDoubleNear( currentVectorLayer->opacity(), 1.0 ) && !( flags & EffectsCheckFlag::IgnoreGeoPdfSupportedEffects ) )
{
layers << layer->name();
}
#endif
if ( currentVectorLayer->featureBlendMode() != QPainter::CompositionMode_SourceOver )
{
layers << layer->name();
@@ -96,7 +96,12 @@ void TestQgsMapSettingsUtils::containsAdvancedEffects()
// changing an individual layer's opacity is OK -- we don't want to force the whole map to be rasterized just because of this setting!
// (just let that one layer get exported as raster instead)
layer->setOpacity( 0.5 );
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
// this only works on Qt 5.15 or later -- see https://github.com/qgis/QGIS/issues/42698
QCOMPARE( QgsMapSettingsUtils::containsAdvancedEffects( mapSettings ).size(), 0 );
#else
QCOMPARE( QgsMapSettingsUtils::containsAdvancedEffects( mapSettings ).size(), 1 );
#endif
QCOMPARE( QgsMapSettingsUtils::containsAdvancedEffects( mapSettings, QgsMapSettingsUtils::EffectsCheckFlag::IgnoreGeoPdfSupportedEffects ).size(), 0 );
}

0 comments on commit 095c0dc

Please sign in to comment.