summaryrefslogtreecommitdiffstats
path: root/qt-ui/models.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-01-07 12:22:22 +0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-01-07 12:22:22 +0800
commita8db19f54829880c222b749394c70cef31d5fb6f (patch)
tree26e491f75c5943da166ca7f9b9897639674c7e5f /qt-ui/models.cpp
parentc3fe1a9e9f79c77c533642df4f986238ef08452b (diff)
downloadsubsurface-a8db19f54829880c222b749394c70cef31d5fb6f.tar.gz
Restructure overly agressive Q_ASSERT
Turns out this function can be called when there is no valid dive - so only protect those parts that dereference the dive. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/models.cpp')
-rw-r--r--qt-ui/models.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
index b39ad89e2..685d64505 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -985,7 +985,6 @@ QVariant DiveItem::data(int column, int role) const
{
QVariant retVal;
struct dive *dive = getDiveById(diveId);
- Q_ASSERT(dive != NULL);
switch (role) {
case Qt::TextAlignmentRole:
@@ -1001,6 +1000,7 @@ QVariant DiveItem::data(int column, int role) const
}
break;
case DiveTripModel::SORT_ROLE:
+ Q_ASSERT(dive != NULL);
switch (column) {
case NR: retVal = (qulonglong) dive->when; break;
case DATE: retVal = (qulonglong) dive->when; break;
@@ -1019,6 +1019,7 @@ QVariant DiveItem::data(int column, int role) const
}
break;
case Qt::DisplayRole:
+ Q_ASSERT(dive != NULL);
switch (column) {
case NR: retVal = dive->number; break;
case DATE: retVal = displayDate(); break;
@@ -1037,13 +1038,15 @@ QVariant DiveItem::data(int column, int role) const
break;
}
- if (role == DiveTripModel::STAR_ROLE)
+ if (role == DiveTripModel::STAR_ROLE) {
+ Q_ASSERT(dive != NULL);
retVal = dive->rating;
-
- if (role == DiveTripModel::DIVE_ROLE)
+ }
+ if (role == DiveTripModel::DIVE_ROLE) {
retVal = QVariant::fromValue<void*>(dive);
-
+ }
if(role == DiveTripModel::DIVE_IDX){
+ Q_ASSERT(dive != NULL);
retVal = get_divenr(dive);
}
return retVal;