Skip to content
Permalink
Browse files
Add some safety checks
  • Loading branch information
nyalldawson committed May 6, 2017
1 parent 57b1a39 commit baa6592
Showing 1 changed file with 7 additions and 1 deletion.
@@ -265,6 +265,9 @@ void QgsComposerMap::cache()
}
}

if ( w <= 0 || h <= 0 )
return;

mCacheRenderingImage.reset( new QImage( w, h, QImage::Format_ARGB32 ) );

// set DPI of the image
@@ -306,7 +309,7 @@ void QgsComposerMap::paint( QPainter *painter, const QStyleOptionGraphicsItem *,
{
Q_UNUSED( pWidget );

if ( !mComposition || !painter )
if ( !mComposition || !painter || !painter->device() )
{
return;
}
@@ -316,6 +319,9 @@ void QgsComposerMap::paint( QPainter *painter, const QStyleOptionGraphicsItem *,
}

QRectF thisPaintRect = QRectF( 0, 0, QGraphicsRectItem::rect().width(), QGraphicsRectItem::rect().height() );
if ( thisPaintRect.width() == 0 || thisPaintRect.height() == 0 )
return;

painter->save();
painter->setClipRect( thisPaintRect );

0 comments on commit baa6592

Please sign in to comment.