Fix crasher

m_dives can be empty, so make sure we don't push an invalid QModelIndex
into the mode.

Signed-off-by: Sebastian Kügler <sebas@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Sebastian Kügler 2015-12-03 21:22:18 +01:00 committed by Dirk Hohndel
parent 7d2a7da079
commit 9ef475844d

View file

@ -17,9 +17,11 @@ void DiveListModel::addDive(dive *d)
void DiveListModel::clear()
{
beginRemoveRows(QModelIndex(), 0, m_dives.count() - 1);
m_dives.clear();
endRemoveRows();
if (m_dives.count()) {
beginRemoveRows(QModelIndex(), 0, m_dives.count() - 1);
m_dives.clear();
endRemoveRows();
}
}
int DiveListModel::rowCount(const QModelIndex &) const