From f67b3a985274438153ff973ebe56128e353ff81f Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sun, 9 Jul 2017 16:04:31 -0700 Subject: DiveImportedModel: be consistent with last = -1 Signed-off-by: Dirk Hohndel --- qt-models/diveimportedmodel.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'qt-models') 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() -- cgit v1.2.3-70-g09d2