From 021d799ff9346e602b8a19c296610a9bda98d970 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Sat, 15 Feb 2014 20:44:49 -0200 Subject: Fix crash opening testdive0.xml That particular dive didn't have a temperature, and thus we got a crash while accessing the last temperature text. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/profile/diveprofileitem.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp index a07132fbb..58dfa4933 100644 --- a/qt-ui/profile/diveprofileitem.cpp +++ b/qt-ui/profile/diveprofileitem.cpp @@ -267,7 +267,8 @@ void DiveTemperatureItem::modelDataChanged(const QModelIndex& topLeft, const QMo ((abs(last_valid_temp - last_printed_temp) > 500) || ((double)last / (double)sec < 0.75))) { createTextItem(sec, last_valid_temp); } - texts.last()->setAlignment(Qt::AlignLeft | Qt::AlignBottom); + if( texts.count()) + texts.last()->setAlignment(Qt::AlignLeft | Qt::AlignBottom); } void DiveTemperatureItem::createTextItem(int sec, int mkelvin) -- cgit v1.2.3-70-g09d2