From 65371ec1b83c2e31b2c47cf22ea46b6a50c37e86 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 26 Jul 2017 15:24:18 +0300 Subject: [PATCH] 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. --- Telegram/SourceFiles/ui/text/text.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/ui/text/text.cpp b/Telegram/SourceFiles/ui/text/text.cpp index 9ab139403..d18a8ea55 100644 --- a/Telegram/SourceFiles/ui/text/text.cpp +++ b/Telegram/SourceFiles/ui/text/text.cpp @@ -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) {