Skip to content

Commit

Permalink
[layouts] Restore forced rasterization of whole layout map item
Browse files Browse the repository at this point in the history
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 committed Jun 23, 2021
1 parent c9ad090 commit 764dedc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/core/qgsmapsettingsutils.cpp
Expand Up @@ -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();
Expand Down
5 changes: 5 additions & 0 deletions tests/src/core/testqgsmapsettingsutils.cpp
Expand Up @@ -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 );
}

Expand Down

0 comments on commit 764dedc

Please sign in to comment.