summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Leinir Turthra Jensen <admin@leinir.dk>2016-04-25 07:28:50 (GMT)
committerDan Leinir Turthra Jensen <admin@leinir.dk>2016-04-25 07:28:50 (GMT)
commitd01a5704bf14d0b1b9795512ce235a8abb680fc1 (patch)
tree581a0f23c5335808fcc714f2cad27b66949dfc74
parent8bcfc5d0b4d803275a301357bebc94eb2d09dedb (diff)
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.
-rw-r--r--mobile/components/pageitem.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/mobile/components/pageitem.cpp b/mobile/components/pageitem.cpp
index cef38ea..da165f1 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();