diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2021-01-26 18:35:48 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2021-04-02 13:53:23 -0700 |
commit | 752724aa1e077ba491a7e4f687e6a1d9b787b61d (patch) | |
tree | 9117f78417fb71ef59bc9c554f00e1344d68ae3a /profile-widget | |
parent | 1ec0790d504d8a9d5e6694afff04f9ae92d01af8 (diff) | |
download | subsurface-752724aa1e077ba491a7e4f687e6a1d9b787b61d.tar.gz |
profile: fix logic in keyDeleteAction()
The code took care to not delete planner-points when no
points are selected. However, it assumed that all selected
objects are planner-points. But then it checked whether
the selected object actually is a planner-point. So which
is it?
Remove the outter check for an empty selection. This makes
things more logical and more robust, should there ever
be other objects that can be selected.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'profile-widget')
-rw-r--r-- | profile-widget/profilewidget2.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index b20e6af51..7b6fb9b65 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -1910,17 +1910,15 @@ void ProfileWidget2::keyDeleteAction() if ((currentState != ADD && currentState != PLAN) || !plannerModel) return; - int selCount = scene()->selectedItems().count(); - if (selCount) { - QVector<int> selectedIndices; - Q_FOREACH (QGraphicsItem *i, scene()->selectedItems()) { - if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler *>(i)) { - selectedIndices.push_back(handleIndex(handler)); - handler->hide(); - } + QVector<int> selectedIndices; + Q_FOREACH (QGraphicsItem *i, scene()->selectedItems()) { + if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler *>(i)) { + selectedIndices.push_back(handleIndex(handler)); + handler->hide(); } - plannerModel->removeSelectedPoints(selectedIndices); } + if (!selectedIndices.isEmpty()) + plannerModel->removeSelectedPoints(selectedIndices); } void ProfileWidget2::keyEscAction() |