Skip to content

Commit

Permalink
Don't draw annotation text outside of painter's clip region (fix #10400)
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 5, 2014
1 parent 2ff1d32 commit af0d68c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/gui/qgstextannotationitem.cpp
Expand Up @@ -64,8 +64,16 @@ void QgsTextAnnotationItem::paint( QPainter * painter )
painter->translate( mOffsetFromReferencePoint.x() + frameWidth / 2.0,
mOffsetFromReferencePoint.y() + frameWidth / 2.0 );

QRectF clipRect = QRectF( 0, 0, mFrameSize.width() - frameWidth / 2.0, mFrameSize.height() - frameWidth / 2.0 ) ;
if ( painter->hasClipping() )
{
//QTextDocument::drawContents will draw text outside of the painter's clip region
//when it is passed a clip rectangle. So, we need to intersect it with the
//painter's clip region to prevent text drawn outside clipped region (eg, outside composer maps, see #10400)
clipRect = clipRect.intersected( painter->clipRegion().boundingRect() );
}
//draw text document
mDocument->drawContents( painter, QRectF( 0, 0, mFrameSize.width() - frameWidth / 2.0, mFrameSize.height() - frameWidth / 2.0 ) );
mDocument->drawContents( painter, clipRect );
painter->restore();
if ( isSelected() )
{
Expand Down

0 comments on commit af0d68c

Please sign in to comment.