Fix selected text render on Retina.

QPainter::viewport() can be a too large rect to be passed as a
clipping region to QPainter on Retina displays.

QPainter in case of Retina displays tries to transform QRegion using
scale matrix and fails with "QRegion: creating region from big
polygon failed" warning message and disables painting completely.
This commit is contained in:
John Preston 2017-07-26 15:24:18 +03:00
parent 647d6ae443
commit 65371ec1b8
1 changed files with 2 additions and 1 deletions

View File

@ -1517,7 +1517,8 @@ private:
_p->setClipRect(selectedRect, Qt::IntersectClip);
_p->setPen(*_currentPenSelected);
_p->drawTextItem(QPointF(x.toReal(), textY), gf);
_p->setClipRegion((clippingEnabled ? clippingRegion : QRegion(_p->viewport())) - selectedRect);
auto externalClipping = clippingEnabled ? clippingRegion : QRegion(QRect((_x - _w).toInt(), _y - _lineHeight, (_x + 2 * _w).toInt(), _y + 2 * _lineHeight));
_p->setClipRegion(externalClipping - selectedRect);
_p->setPen(*_currentPen);
_p->drawTextItem(QPointF(x.toReal(), textY), gf);
if (clippingEnabled) {