QtQuick: simplify PageItem

Don't compare the limits to itself
This commit is contained in:
Aleix Pol 2018-04-26 01:32:27 +02:00
parent 970e0f2ba9
commit a082ace479

View file

@ -344,18 +344,14 @@ void PageItem::paint()
const int flags = PagePainter::Accessibility | PagePainter::Highlights | PagePainter::Annotations; const int flags = PagePainter::Accessibility | PagePainter::Highlights | PagePainter::Annotations;
// Simply using the limits as described by textureSize will, at times, result in the page painter // Simply using the limits as described by textureSize will, at times, result in the page painter
// attempting to write outside the data area, unsurprisingly resulting in a crash. // attempting to write outside the data area, unsurprisingly resulting in a crash.
QRect limits(QPoint(0, 0), QSize(width(), height()));
if(limits.width() > width())
limits.setWidth(width());
if(limits.height() > height())
limits.setHeight(height());
QSize size(width()*dpr, height()*dpr); if (width() <= 0 || height() < 0) {
if (size.isNull()) { update();
return; return;
} }
QPixmap pix(size); const QRect limits(QPoint(0, 0), QSize(width()*dpr, height()*dpr));
QPixmap pix(limits.size());
pix.setDevicePixelRatio(dpr); pix.setDevicePixelRatio(dpr);
QPainter p(&pix); QPainter p(&pix);
p.setRenderHint(QPainter::Antialiasing, m_smooth); p.setRenderHint(QPainter::Antialiasing, m_smooth);