summaryrefslogtreecommitdiffstats
path: root/profile-widget
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-12-01 15:20:32 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-12-01 15:20:32 -0800
commit9dd26a00e86eb0c7e5f0f9650f021b24e73d67df (patch)
treebc92795fcb411d6240c609ecbca7a3c93e4f987f /profile-widget
parentdcce7358ff982f01764a7f373a531092e868ca81 (diff)
downloadsubsurface-9dd26a00e86eb0c7e5f0f9650f021b24e73d67df.tar.gz
Profile: avoid potential crash
If things go as planned, then the length of the polygon is the same as the number of rows in the model. Turns out when running Subsurface-mobile on Android that simple truth doesn't seem to be correct. Most of the time the polygon seems to have twice as many elements as the model. But a few times I ended up in here with a polygon that had fewer elements than the model. And then things crash. This simply avoids the crash. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'profile-widget')
-rw-r--r--profile-widget/diveprofileitem.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/profile-widget/diveprofileitem.cpp b/profile-widget/diveprofileitem.cpp
index ca87f4ed0..849a9d3de 100644
--- a/profile-widget/diveprofileitem.cpp
+++ b/profile-widget/diveprofileitem.cpp
@@ -135,7 +135,8 @@ void DiveProfileItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
QModelIndex colorIndex = dataModel->index(i, DivePlotDataModel::COLOR);
pen.setBrush(QBrush(colorIndex.data(Qt::BackgroundRole).value<QColor>()));
painter->setPen(pen);
- painter->drawLine(poly[i - 1], poly[i]);
+ if (i < poly.count())
+ painter->drawLine(poly[i - 1], poly[i]);
}
painter->restore();
}