mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
c3fe1a9e9f
commit
a8db19f548
1 changed files with 8 additions and 5 deletions
|
@ -985,7 +985,6 @@ QVariant DiveItem::data(int column, int role) const
|
||||||
{
|
{
|
||||||
QVariant retVal;
|
QVariant retVal;
|
||||||
struct dive *dive = getDiveById(diveId);
|
struct dive *dive = getDiveById(diveId);
|
||||||
Q_ASSERT(dive != NULL);
|
|
||||||
|
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Qt::TextAlignmentRole:
|
case Qt::TextAlignmentRole:
|
||||||
|
@ -1001,6 +1000,7 @@ QVariant DiveItem::data(int column, int role) const
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DiveTripModel::SORT_ROLE:
|
case DiveTripModel::SORT_ROLE:
|
||||||
|
Q_ASSERT(dive != NULL);
|
||||||
switch (column) {
|
switch (column) {
|
||||||
case NR: retVal = (qulonglong) dive->when; break;
|
case NR: retVal = (qulonglong) dive->when; break;
|
||||||
case DATE: 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;
|
break;
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
|
Q_ASSERT(dive != NULL);
|
||||||
switch (column) {
|
switch (column) {
|
||||||
case NR: retVal = dive->number; break;
|
case NR: retVal = dive->number; break;
|
||||||
case DATE: retVal = displayDate(); break;
|
case DATE: retVal = displayDate(); break;
|
||||||
|
@ -1037,13 +1038,15 @@ QVariant DiveItem::data(int column, int role) const
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (role == DiveTripModel::STAR_ROLE)
|
if (role == DiveTripModel::STAR_ROLE) {
|
||||||
|
Q_ASSERT(dive != NULL);
|
||||||
retVal = dive->rating;
|
retVal = dive->rating;
|
||||||
|
}
|
||||||
if (role == DiveTripModel::DIVE_ROLE)
|
if (role == DiveTripModel::DIVE_ROLE) {
|
||||||
retVal = QVariant::fromValue<void*>(dive);
|
retVal = QVariant::fromValue<void*>(dive);
|
||||||
|
}
|
||||||
if(role == DiveTripModel::DIVE_IDX){
|
if(role == DiveTripModel::DIVE_IDX){
|
||||||
|
Q_ASSERT(dive != NULL);
|
||||||
retVal = get_divenr(dive);
|
retVal = get_divenr(dive);
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
|
|
Loading…
Add table
Reference in a new issue