summaryrefslogtreecommitdiffstats
path: root/qt-models
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2017-07-09 16:04:31 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-07-09 16:04:31 -0700
commitf67b3a985274438153ff973ebe56128e353ff81f (patch)
tree8cb9b7f82f4c6e6e1135eb3827136a8f78c07368 /qt-models
parentfd96daca6a170bfd2ecac45b403c93c63b8473d2 (diff)
downloadsubsurface-f67b3a985274438153ff973ebe56128e353ff81f.tar.gz
DiveImportedModel: be consistent with last = -1
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-models')
-rw-r--r--qt-models/diveimportedmodel.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/qt-models/diveimportedmodel.cpp b/qt-models/diveimportedmodel.cpp
index 66be4b5cf..e9e0c45d8 100644
--- a/qt-models/diveimportedmodel.cpp
+++ b/qt-models/diveimportedmodel.cpp
@@ -139,26 +139,24 @@ void DiveImportedModel::clearTable()
void DiveImportedModel::setImportedDivesIndexes(int first, int last)
{
- Q_ASSERT(last >= first);
if (lastIndex >= firstIndex) {
beginRemoveRows(QModelIndex(), 0, lastIndex - firstIndex);
endRemoveRows();
}
- beginInsertRows(QModelIndex(), 0, last - first);
+ if (last >= first)
+ beginInsertRows(QModelIndex(), 0, last - first);
lastIndex = last;
firstIndex = first;
delete[] checkStates;
checkStates = new bool[last - first + 1];
memset(checkStates, true, last - first + 1);
- endInsertRows();
+ if (last >= first)
+ endInsertRows();
}
void DiveImportedModel::repopulate()
{
- if (diveTable->nr)
- setImportedDivesIndexes(0, diveTable->nr-1);
- else
- setImportedDivesIndexes(0, 0);
+ setImportedDivesIndexes(0, diveTable->nr-1);
}
void DiveImportedModel::recordDives()