From 752724aa1e077ba491a7e4f687e6a1d9b787b61d Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Tue, 26 Jan 2021 18:35:48 +0100 Subject: 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 --- profile-widget/profilewidget2.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'profile-widget') 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 selectedIndices; - Q_FOREACH (QGraphicsItem *i, scene()->selectedItems()) { - if (DiveHandler *handler = qgraphicsitem_cast(i)) { - selectedIndices.push_back(handleIndex(handler)); - handler->hide(); - } + QVector selectedIndices; + Q_FOREACH (QGraphicsItem *i, scene()->selectedItems()) { + if (DiveHandler *handler = qgraphicsitem_cast(i)) { + selectedIndices.push_back(handleIndex(handler)); + handler->hide(); } - plannerModel->removeSelectedPoints(selectedIndices); } + if (!selectedIndices.isEmpty()) + plannerModel->removeSelectedPoints(selectedIndices); } void ProfileWidget2::keyEscAction() -- cgit v1.2.3-70-g09d2