- the painting is ended if image cannot be allocated in renderer
This commit is contained in:
vmora 2013-07-29 15:51:43 +02:00
parent e0a0a3a948
commit eeaa867e10
2 changed files with 15 additions and 0 deletions

View File

@ -2014,6 +2014,7 @@ QImage QgsComposition::printPageAsRaster( int page )
image.fill( 0 );
QPainter imagePainter( &image );
renderPage( &imagePainter, page );
if ( !imagePainter.isActive() ) return QImage();
}
return image;
}

View File

@ -463,6 +463,13 @@ void QgsMapRenderer::render( QPainter* painter, double* forceWidthScale )
QgsDebugMsg( "Caching enabled but layer redraw forced by extent change or empty cache" );
QImage * mypImage = new QImage( mRenderContext.painter()->device()->width(),
mRenderContext.painter()->device()->height(), QImage::Format_ARGB32 );
if ( mypImage->isNull() )
{
QgsDebugMsg( "insufficient memory for image " + QString::number(mRenderContext.painter()->device()->width()) + "x" + QString::number(mRenderContext.painter()->device()->height()) );
emit drawError( ml );
painter->end(); // drawError is not caught by anyone, so we end painting to notify caller
return;
}
mypImage->fill( 0 );
ml->setCacheImage( mypImage ); //no need to delete the old one, maplayer does it for you
QPainter * mypPainter = new QPainter( ml->cacheImage() );
@ -501,6 +508,13 @@ void QgsMapRenderer::render( QPainter* painter, double* forceWidthScale )
flattenedLayer = true;
mypFlattenedImage = new QImage( mRenderContext.painter()->device()->width(),
mRenderContext.painter()->device()->height(), QImage::Format_ARGB32 );
if ( mypFlattenedImage->isNull() )
{
QgsDebugMsg( "insufficient memory for image " + QString::number(mRenderContext.painter()->device()->width()) + "x" + QString::number(mRenderContext.painter()->device()->height()) );
emit drawError( ml );
painter->end(); // drawError is not caught by anyone, so we end painting to notify caller
return;
}
mypFlattenedImage->fill( 0 );
QPainter * mypPainter = new QPainter( mypFlattenedImage );
if ( mySettings.value( "/qgis/enable_anti_aliasing", true ).toBool() )