Skip to content

Commit

Permalink
Add some safety checks
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 6, 2017
1 parent 57b1a39 commit baa6592
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/core/composer/qgscomposermap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -306,7 +309,7 @@ void QgsComposerMap::paint( QPainter *painter, const QStyleOptionGraphicsItem *,
{
Q_UNUSED( pWidget );

if ( !mComposition || !painter )
if ( !mComposition || !painter || !painter->device() )
{
return;
}
Expand All @@ -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 );

Expand Down

0 comments on commit baa6592

Please sign in to comment.