From 9ef475844dbe55540ca4f53932c27ab1ce59c09d Mon Sep 17 00:00:00 2001 From: Sebastian Kügler Date: Thu, 3 Dec 2015 21:22:18 +0100 Subject: Fix crasher MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit m_dives can be empty, so make sure we don't push an invalid QModelIndex into the mode. Signed-off-by: Sebastian Kügler Signed-off-by: Dirk Hohndel --- qt-models/divelistmodel.cpp | 8 +++++--- 1 file 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 -- cgit v1.2.3-70-g09d2