From cf9748278fe2a44bcdbdf6d7428ea93491cc5ed8 Mon Sep 17 00:00:00 2001 From: "Lubomir I. Ivanov" Date: Tue, 10 Dec 2013 01:02:06 +0200 Subject: Planner: fix potential assert in clear() If rowCount() is 0 we get an assert: ASSERT: "last >= first" in file kernel/qabstractitemmodel.cpp... To solve that we wrap the beginRemoveRows() call in a bnrach: if (rowCount() > 0) { ... Signed-off-by: Lubomir I. Ivanov Signed-off-by: Dirk Hohndel --- qt-ui/diveplanner.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index c5ca7f74c..dedbd617d 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -1396,9 +1396,11 @@ void DivePlannerPointsModel::clear() memset(stagingDive->cylinder, 0, MAX_CYLINDERS * sizeof(cylinder_t)); } CylindersModel::instance()->setDive(stagingDive); - beginRemoveRows(QModelIndex(), 0, rowCount()-1); - divepoints.clear(); - endRemoveRows(); + if (rowCount() > 0) { + beginRemoveRows(QModelIndex(), 0, rowCount() - 1); + divepoints.clear(); + endRemoveRows(); + } CylindersModel::instance()->clear(); } -- cgit v1.2.3-70-g09d2