Skip to content

Commit eeaa867

Browse files
committed
- fix #7926
- the painting is ended if image cannot be allocated in renderer
1 parent e0a0a3a commit eeaa867

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

‎src/core/composer/qgscomposition.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2014,6 +2014,7 @@ QImage QgsComposition::printPageAsRaster( int page )
20142014
image.fill( 0 );
20152015
QPainter imagePainter( &image );
20162016
renderPage( &imagePainter, page );
2017+
if ( !imagePainter.isActive() ) return QImage();
20172018
}
20182019
return image;
20192020
}

‎src/core/qgsmaprenderer.cpp‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,13 @@ void QgsMapRenderer::render( QPainter* painter, double* forceWidthScale )
463463
QgsDebugMsg( "Caching enabled but layer redraw forced by extent change or empty cache" );
464464
QImage * mypImage = new QImage( mRenderContext.painter()->device()->width(),
465465
mRenderContext.painter()->device()->height(), QImage::Format_ARGB32 );
466+
if ( mypImage->isNull() )
467+
{
468+
QgsDebugMsg( "insufficient memory for image " + QString::number(mRenderContext.painter()->device()->width()) + "x" + QString::number(mRenderContext.painter()->device()->height()) );
469+
emit drawError( ml );
470+
painter->end(); // drawError is not caught by anyone, so we end painting to notify caller
471+
return;
472+
}
466473
mypImage->fill( 0 );
467474
ml->setCacheImage( mypImage ); //no need to delete the old one, maplayer does it for you
468475
QPainter * mypPainter = new QPainter( ml->cacheImage() );
@@ -501,6 +508,13 @@ void QgsMapRenderer::render( QPainter* painter, double* forceWidthScale )
501508
flattenedLayer = true;
502509
mypFlattenedImage = new QImage( mRenderContext.painter()->device()->width(),
503510
mRenderContext.painter()->device()->height(), QImage::Format_ARGB32 );
511+
if ( mypFlattenedImage->isNull() )
512+
{
513+
QgsDebugMsg( "insufficient memory for image " + QString::number(mRenderContext.painter()->device()->width()) + "x" + QString::number(mRenderContext.painter()->device()->height()) );
514+
emit drawError( ml );
515+
painter->end(); // drawError is not caught by anyone, so we end painting to notify caller
516+
return;
517+
}
504518
mypFlattenedImage->fill( 0 );
505519
QPainter * mypPainter = new QPainter( mypFlattenedImage );
506520
if ( mySettings.value( "/qgis/enable_anti_aliasing", true ).toBool() )

0 commit comments

Comments
 (0)