Don't try to compose images before they have been initialized

This commit is contained in:
Nyall Dawson 2017-03-26 17:33:43 +10:00
parent 7aa4fa090b
commit 8b9e4922fc
4 changed files with 14 additions and 0 deletions

View File

@ -257,7 +257,10 @@ void QgsMapRendererCustomPainterJob::doRender()
layerTime.start();
if ( job.img )
{
job.img->fill( 0 );
job.imageInitialized = true;
}
job.renderer->render();

View File

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

View File

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

View File

@ -244,7 +244,10 @@ void QgsMapRendererParallelJob::renderLayerStatic( LayerRenderJob &job )
return;
if ( job.img )
{
job.img->fill( 0 );
job.imageInitialized = true;
}
QTime t;
t.start();