Skip to content
Permalink
Browse files

[vectortiles] Don't overwrite existing QPainter clip regions

This can overwrite valid clip regions setup outside of the vector tile
renderer, e.g. by a layout map item.

Fixes #37443
  • Loading branch information
nyalldawson committed Jul 2, 2020
1 parent 7af9090 commit 2a17e7b06f46bfcf38bef4977f25a3849351b477
Showing with 7 additions and 4 deletions.
  1. +7 −4 src/core/vectortile/qgsvectortilelayerrenderer.cpp
@@ -62,6 +62,8 @@ bool QgsVectorTileLayerRenderer::render()
if ( ctx.renderingStopped() )
return false;

QgsScopedQPainterState painterState( ctx.painter() );

QElapsedTimer tTotal;
tTotal.start();

@@ -165,8 +167,6 @@ bool QgsVectorTileLayerRenderer::render()

mRenderer->stopRender( ctx );

ctx.painter()->setClipping( false );

QgsDebugMsgLevel( QStringLiteral( "Total time for decoding: %1" ).arg( mTotalDecodeTime / 1000. ), 2 );
QgsDebugMsgLevel( QStringLiteral( "Drawing time: %1" ).arg( mTotalDrawTime / 1000. ), 2 );
QgsDebugMsgLevel( QStringLiteral( "Total time: %1" ).arg( tTotal.elapsed() / 1000. ), 2 );
@@ -209,8 +209,10 @@ void QgsVectorTileLayerRenderer::decodeAndDrawTile( const QgsVectorTileRawData &
return;

// set up clipping so that rendering does not go behind tile's extent

ctx.painter()->setClipRegion( QRegion( tile.tilePolygon() ) );
QgsScopedQPainterState savePainterState( ctx.painter() );
// we have to intersect with any existing painter clip regions, or we risk overwriting valid clip
// regions setup outside of the vector tile renderer (e.g. layout map clip region)
ctx.painter()->setClipRegion( QRegion( tile.tilePolygon() ), Qt::IntersectClip );

QElapsedTimer tDraw;
tDraw.start();
@@ -223,6 +225,7 @@ void QgsVectorTileLayerRenderer::decodeAndDrawTile( const QgsVectorTileRawData &

if ( mDrawTileBoundaries )
{
QgsScopedQPainterState savePainterState( ctx.painter() );
ctx.painter()->setClipping( false );

QPen pen( Qt::red );

0 comments on commit 2a17e7b

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