Skip to content

Commit

Permalink
profile: remove redundant replot() calls in key events
Browse files Browse the repository at this point in the history
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 <bstoeger@mail.tuwien.ac.at>
  • Loading branch information
bstoeger authored and dirkhh committed Apr 2, 2021
1 parent a3d8191 commit 457be51
Showing 1 changed file with 0 additions and 13 deletions.
13 changes: 0 additions & 13 deletions profile-widget/profilewidget2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<DiveHandler *>(i)) {
int row = handleIndex(handler);
Expand All @@ -1824,16 +1822,13 @@ void ProfileWidget2::keyDownAction()
plannerModel->editStop(row, dp);
}
}
plannerModel->setRecalc(oldRecalc);
replot();
}

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<DiveHandler *>(i)) {
int row = handleIndex(handler);
Expand All @@ -1846,16 +1841,13 @@ void ProfileWidget2::keyUpAction()
plannerModel->editStop(row, dp);
}
}
plannerModel->setRecalc(oldRecalc);
replot();
}

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<DiveHandler *>(i)) {
int row = handleIndex(handler);
Expand All @@ -1868,16 +1860,13 @@ void ProfileWidget2::keyLeftAction()
plannerModel->editStop(row, dp);
}
}
plannerModel->setRecalc(oldRecalc);
replot();
}

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<DiveHandler *>(i)) {
int row = handleIndex(handler);
Expand All @@ -1887,8 +1876,6 @@ void ProfileWidget2::keyRightAction()
plannerModel->editStop(row, dp);
}
}
plannerModel->setRecalc(oldRecalc);
replot();
}

void ProfileWidget2::keyDeleteAction()
Expand Down

0 comments on commit 457be51

Please sign in to comment.