Skip to content
Permalink
Browse files
Don't try to compose images before they have been initialized
  • Loading branch information
nyalldawson committed Mar 26, 2017
1 parent 7aa4fa0 commit 8b9e4922fc69b97086f3d54f3ddefc722497ee01
@@ -257,7 +257,10 @@ void QgsMapRendererCustomPainterJob::doRender()
layerTime.start();

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

job.renderer->render();

@@ -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 );

@@ -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 );

@@ -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;
@@ -244,7 +244,10 @@ void QgsMapRendererParallelJob::renderLayerStatic( LayerRenderJob &job )
return;

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

QTime t;
t.start();

0 comments on commit 8b9e492

Please sign in to comment.