diff options
author | Lubomir I. Ivanov <neolit123@gmail.com> | 2013-12-10 01:02:06 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-12-10 05:22:01 +0100 |
commit | cf9748278fe2a44bcdbdf6d7428ea93491cc5ed8 (patch) | |
tree | ed14c33f5bb34c2c073a7e7161c2e9153a9f5c2c | |
parent | 26a1904cf88a97474468fab33879a0c3235e56ac (diff) | |
download | subsurface-cf9748278fe2a44bcdbdf6d7428ea93491cc5ed8.tar.gz |
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>
-rw-r--r-- | qt-ui/diveplanner.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
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(); } |