After DC import don't do RemoveRows if there is nothing to remove

This fixes an issue where beginRemoveRows is called with argument -1
in DiveImportedModel::setImportedDivesIndexes.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
This commit is contained in:
Stefan Fuchs 2017-04-21 19:46:13 +02:00 committed by Dirk Hohndel
parent 441cfb3f05
commit 02e768a61b

View file

@ -733,8 +733,10 @@ void DiveImportedModel::clearTable()
void DiveImportedModel::setImportedDivesIndexes(int first, int last)
{
Q_ASSERT(last >= first);
beginRemoveRows(QModelIndex(), 0, lastIndex - firstIndex);
endRemoveRows();
if (lastIndex >= firstIndex) {
beginRemoveRows(QModelIndex(), 0, lastIndex - firstIndex);
endRemoveRows();
}
beginInsertRows(QModelIndex(), 0, last - first);
lastIndex = last;
firstIndex = first;