From a8db19f54829880c222b749394c70cef31d5fb6f Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Tue, 7 Jan 2014 12:22:22 +0800 Subject: 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 --- qt-ui/models.cpp | 13 ++++++++----- 1 file 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(dive); - + } if(role == DiveTripModel::DIVE_IDX){ + Q_ASSERT(dive != NULL); retVal = get_divenr(dive); } return retVal; -- cgit v1.2.3-70-g09d2