From 457be51ff66fb7c3396863a27f4d93de1877e3b2 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Tue, 23 Feb 2021 20:11:44 +0100 Subject: profile: remove redundant replot() calls in key events When moving "dive handlers" with the cursor keys, the profile was replot twice: - First the recalculation of the planner model was suspended. - The "stop" was moved. - This led to a replot by a signal from the planner model. However, the old profile was shown, since the recalculation was suspended. - The recalculation was reenabled. - The profile war replot, resulting now in the correct profile. A classical case of bit rot. Instead, don't suspend calculation in the first place. This shows the correct profile on the first replot and the second replot can be removed. Signed-off-by: Berthold Stoeger --- profile-widget/profilewidget2.cpp | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'profile-widget') diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index f1dfc263f..d5cae62a4 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -1813,8 +1813,6 @@ void ProfileWidget2::keyDownAction() if ((currentState != ADD && currentState != PLAN) || !plannerModel) return; - bool oldRecalc = plannerModel->setRecalc(false); - Q_FOREACH (QGraphicsItem *i, scene()->selectedItems()) { if (DiveHandler *handler = qgraphicsitem_cast(i)) { int row = handleIndex(handler); @@ -1824,8 +1822,6 @@ void ProfileWidget2::keyDownAction() plannerModel->editStop(row, dp); } } - plannerModel->setRecalc(oldRecalc); - replot(); } void ProfileWidget2::keyUpAction() @@ -1833,7 +1829,6 @@ void ProfileWidget2::keyUpAction() if ((currentState != ADD && currentState != PLAN) || !plannerModel) return; - bool oldRecalc = plannerModel->setRecalc(false); Q_FOREACH (QGraphicsItem *i, scene()->selectedItems()) { if (DiveHandler *handler = qgraphicsitem_cast(i)) { int row = handleIndex(handler); @@ -1846,8 +1841,6 @@ void ProfileWidget2::keyUpAction() plannerModel->editStop(row, dp); } } - plannerModel->setRecalc(oldRecalc); - replot(); } void ProfileWidget2::keyLeftAction() @@ -1855,7 +1848,6 @@ void ProfileWidget2::keyLeftAction() if ((currentState != ADD && currentState != PLAN) || !plannerModel) return; - bool oldRecalc = plannerModel->setRecalc(false); Q_FOREACH (QGraphicsItem *i, scene()->selectedItems()) { if (DiveHandler *handler = qgraphicsitem_cast(i)) { int row = handleIndex(handler); @@ -1868,8 +1860,6 @@ void ProfileWidget2::keyLeftAction() plannerModel->editStop(row, dp); } } - plannerModel->setRecalc(oldRecalc); - replot(); } void ProfileWidget2::keyRightAction() @@ -1877,7 +1867,6 @@ void ProfileWidget2::keyRightAction() if ((currentState != ADD && currentState != PLAN) || !plannerModel) return; - bool oldRecalc = plannerModel->setRecalc(false); Q_FOREACH (QGraphicsItem *i, scene()->selectedItems()) { if (DiveHandler *handler = qgraphicsitem_cast(i)) { int row = handleIndex(handler); @@ -1887,8 +1876,6 @@ void ProfileWidget2::keyRightAction() plannerModel->editStop(row, dp); } } - plannerModel->setRecalc(oldRecalc); - replot(); } void ProfileWidget2::keyDeleteAction() -- cgit v1.2.3-70-g09d2