From d01a5704bf14d0b1b9795512ce235a8abb680fc1 Mon Sep 17 00:00:00 2001 From: Dan Leinir Turthra Jensen Date: Mon, 25 Apr 2016 08:28:50 +0100 Subject: [PATCH] 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. --- mobile/components/pageitem.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mobile/components/pageitem.cpp b/mobile/components/pageitem.cpp index cef38ea49..da165f1be 100644 --- a/mobile/components/pageitem.cpp +++ b/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();