Avoid a crash occurring when pushing the components a little hard

The situation described here occurs in particular when first increasing
the size of the component considerably, and then reducing it again
(such as switching to and from full screen in some application)
Error discovered in Peruse, but will happen elsewhere as well.
frameworks
Dan Leinir Turthra Jensen 10 years ago
parent 8bcfc5d0b4
commit d01a5704bf
  1. 9
      mobile/components/pageitem.cpp

@ -318,7 +318,14 @@ void PageItem::paint(QPainter *painter)
m_intentionalDraw = false;
}
const int flags = PagePainter::Accessibility | PagePainter::Highlights | PagePainter::Annotations;
PagePainter::paintPageOnPainter(painter, m_page, observer, flags, width(), height(), QRect(QPoint(0,0), contentsSize()));
// Simply using the limits as described by contentsSize will, at times, result in the page painter
// attempting to write outside the data area, unsurprisingly resulting in a crash.
QRect limits(QPoint(0, 0), contentsSize());
if(limits.width() > width())
limits.setWidth(width());
if(limits.height() > height())
limits.setHeight(height());
PagePainter::paintPageOnPainter(painter, m_page, observer, flags, width(), height(), limits);
if (setAA) {
painter->restore();

Loading…
Cancel
Save