Skip to content

Commit

Permalink
[layouts] When determining whether a layout requires rasterization
Browse files Browse the repository at this point in the history
in order to export correctly, skip over any items which aren't visible

These don't affect the output in any way, so showing warnings about
forced rasterization is misleading
  • Loading branch information
nyalldawson committed May 6, 2021
1 parent 5eb2d72 commit 6a9133c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/core/layout/qgslayoutexporter.cpp
Expand Up @@ -1926,7 +1926,8 @@ bool QgsLayoutExporter::requiresRasterization( const QgsLayout *layout )

for ( QgsLayoutItem *currentItem : std::as_const( items ) )
{
if ( currentItem->requiresRasterization() )
// ignore invisible items, they won't affect the output in any way...
if ( currentItem->isVisible() && currentItem->requiresRasterization() )
return true;
}
return false;
Expand All @@ -1942,7 +1943,8 @@ bool QgsLayoutExporter::containsAdvancedEffects( const QgsLayout *layout )

for ( QgsLayoutItem *currentItem : std::as_const( items ) )
{
if ( currentItem->containsAdvancedEffects() )
// ignore invisible items, they won't affect the output in any way...
if ( currentItem->isVisible() && currentItem->containsAdvancedEffects() )
return true;
}
return false;
Expand Down
8 changes: 8 additions & 0 deletions tests/src/python/test_qgslayoutexporter.py
Expand Up @@ -1128,6 +1128,10 @@ def testRequiresRasterization(self):
label.setBlendMode(QPainter.CompositionMode_Overlay)
self.assertTrue(QgsLayoutExporter.requiresRasterization(l))

# but if the item is NOT visible, it won't affect the output in any way..
label.setVisibility(False)
self.assertFalse(QgsLayoutExporter.requiresRasterization(l))

def testContainsAdvancedEffects(self):
"""
Test QgsLayoutExporter.containsAdvancedEffects
Expand All @@ -1146,6 +1150,10 @@ def testContainsAdvancedEffects(self):
label.setItemOpacity(0.5)
self.assertTrue(QgsLayoutExporter.containsAdvancedEffects(l))

# but if the item is NOT visible, it won't affect the output in any way..
label.setVisibility(False)
self.assertFalse(QgsLayoutExporter.containsAdvancedEffects(l))


if __name__ == '__main__':
unittest.main()

0 comments on commit 6a9133c

Please sign in to comment.