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 <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Lubomir I. Ivanov 2013-12-10 01:02:06 +02:00 committed by Dirk Hohndel
parent 26a1904cf8
commit cf9748278f

View file

@ -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);
if (rowCount() > 0) {
beginRemoveRows(QModelIndex(), 0, rowCount() - 1);
divepoints.clear();
endRemoveRows();
}
CylindersModel::instance()->clear();
}