Skip to content

Commit af0d68c

Browse files
committedJun 5, 2014
Don't draw annotation text outside of painter's clip region (fix #10400)
1 parent 2ff1d32 commit af0d68c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed
 

‎src/gui/qgstextannotationitem.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,16 @@ void QgsTextAnnotationItem::paint( QPainter * painter )
6464
painter->translate( mOffsetFromReferencePoint.x() + frameWidth / 2.0,
6565
mOffsetFromReferencePoint.y() + frameWidth / 2.0 );
6666

67+
QRectF clipRect = QRectF( 0, 0, mFrameSize.width() - frameWidth / 2.0, mFrameSize.height() - frameWidth / 2.0 ) ;
68+
if ( painter->hasClipping() )
69+
{
70+
//QTextDocument::drawContents will draw text outside of the painter's clip region
71+
//when it is passed a clip rectangle. So, we need to intersect it with the
72+
//painter's clip region to prevent text drawn outside clipped region (eg, outside composer maps, see #10400)
73+
clipRect = clipRect.intersected( painter->clipRegion().boundingRect() );
74+
}
6775
//draw text document
68-
mDocument->drawContents( painter, QRectF( 0, 0, mFrameSize.width() - frameWidth / 2.0, mFrameSize.height() - frameWidth / 2.0 ) );
76+
mDocument->drawContents( painter, clipRect );
6977
painter->restore();
7078
if ( isSelected() )
7179
{

0 commit comments

Comments
 (0)
Please sign in to comment.