diff options
author | Sebastian Kügler <sebas@kde.org> | 2015-12-03 21:22:18 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-12-03 12:48:51 -0800 |
commit | 9ef475844dbe55540ca4f53932c27ab1ce59c09d (patch) | |
tree | 46d61589352a158301f21ccc4e2a5b567052b02f /qt-models | |
parent | 7d2a7da07919e4287161af60a9ff0482a82e9b7c (diff) | |
download | subsurface-9ef475844dbe55540ca4f53932c27ab1ce59c09d.tar.gz |
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>
Diffstat (limited to 'qt-models')
-rw-r--r-- | qt-models/divelistmodel.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/qt-models/divelistmodel.cpp b/qt-models/divelistmodel.cpp index 18f270c15..86c977fc9 100644 --- a/qt-models/divelistmodel.cpp +++ b/qt-models/divelistmodel.cpp @@ -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 |