diff --git a/ground/openpilotgcs/src/plugins/opmap/flightdatamodel.cpp b/ground/openpilotgcs/src/plugins/opmap/flightdatamodel.cpp index d16c9b381..9fb0787d5 100644 --- a/ground/openpilotgcs/src/plugins/opmap/flightdatamodel.cpp +++ b/ground/openpilotgcs/src/plugins/opmap/flightdatamodel.cpp @@ -469,7 +469,7 @@ bool flightDataModel::insertRows(int row, int count, const QModelIndex & /*paren bool flightDataModel::removeRows(int row, int count, const QModelIndex & /*parent*/) { - if (row < 0) { + if (row < 0 || count <= 0) { return false; } beginRemoveRows(QModelIndex(), row, row + count - 1); diff --git a/ground/openpilotgcs/src/plugins/opmap/modelmapproxy.cpp b/ground/openpilotgcs/src/plugins/opmap/modelmapproxy.cpp index 2dac1b0ac..ab829da75 100644 --- a/ground/openpilotgcs/src/plugins/opmap/modelmapproxy.cpp +++ b/ground/openpilotgcs/src/plugins/opmap/modelmapproxy.cpp @@ -345,7 +345,10 @@ void modelMapProxy::createWayPoint(internals::PointLatLng coord) index = model->index(model->rowCount() - 1, flightDataModel::ERRORDESTINATION, QModelIndex()); model->setData(index, 1, Qt::EditRole); } + void modelMapProxy::deleteAll() { - model->removeRows(0, model->rowCount(), QModelIndex()); + if (model->rowCount() > 0) { + model->removeRows(0, model->rowCount(), QModelIndex()); + } }