Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Don't try to compose images before they have been initialized
  • Loading branch information
nyalldawson committed Mar 26, 2017
1 parent 7aa4fa0 commit 8b9e492
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/core/qgsmaprenderercustompainterjob.cpp
Expand Up @@ -257,7 +257,10 @@ void QgsMapRendererCustomPainterJob::doRender()
layerTime.start();

if ( job.img )
{
job.img->fill( 0 );
job.imageInitialized = true;
}

job.renderer->render();

Expand Down
6 changes: 6 additions & 0 deletions src/core/qgsmaprendererjob.cpp
Expand Up @@ -462,6 +462,9 @@ QImage QgsMapRendererJob::composeImage( const QgsMapSettings &settings, const La
if ( job.layer && job.layer->customProperty( QStringLiteral( "rendering/renderAboveLabels" ) ).toBool() )
continue; // skip layer for now, it will be rendered after labels

if ( !job.imageInitialized )
continue; // img not safe to compose

painter.setCompositionMode( job.blendMode );
painter.setOpacity( job.opacity );

Expand All @@ -488,6 +491,9 @@ QImage QgsMapRendererJob::composeImage( const QgsMapSettings &settings, const La
if ( !job.layer || !job.layer->customProperty( QStringLiteral( "rendering/renderAboveLabels" ) ).toBool() )
continue;

if ( !job.imageInitialized )
continue; // img not safe to compose

painter.setCompositionMode( job.blendMode );
painter.setOpacity( job.opacity );

Expand Down
2 changes: 2 additions & 0 deletions src/core/qgsmaprendererjob.h
Expand Up @@ -46,6 +46,8 @@ struct LayerRenderJob
{
QgsRenderContext context;
QImage *img; // may be null if it is not necessary to draw to separate image (e.g. sequential rendering)
//! True when img has been initialized (filled with transparent pixels) and is safe to compose
bool imageInitialized = false;
QgsMapLayerRenderer *renderer; // must be deleted
QPainter::CompositionMode blendMode;
double opacity;
Expand Down
3 changes: 3 additions & 0 deletions src/core/qgsmaprendererparalleljob.cpp
Expand Up @@ -244,7 +244,10 @@ void QgsMapRendererParallelJob::renderLayerStatic( LayerRenderJob &job )
return;

if ( job.img )
{
job.img->fill( 0 );
job.imageInitialized = true;
}

QTime t;
t.start();
Expand Down

0 comments on commit 8b9e492

Please sign in to comment.