1
0
Fork 0
mirror of https://github.com/subsurface/subsurface.git synced 2025-02-19 22:16:15 +00:00

Undo: simplify profile repainting code

The profile repainting code that was called when a dive changed was
located in a separate function. Not only did it take a redundant
parameter, it also performed very weird stuff like entering and
exiting plan state. That did not work at all. Replace by a simple
call to plotDive() and things work much better.

There was a comment about DivePlannerPointsModel and profile
getting out of sync. So let's keep an eye out for that.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2019-10-14 20:21:15 +02:00 committed by Dirk Hohndel
parent 8dea2ada3b
commit a4ca3c520c

View file

@ -264,18 +264,6 @@ void MainTab::enableEdition(EditMode newEditMode)
editMode = newEditMode != NONE ? newEditMode : DIVE;
}
static void profileFromDive(struct dive *d)
{
// TODO: We have to put these manipulations into a setPlanState()/setProfileState() pair,
// because otherwise the DivePlannerPointsModel and the profile get out of sync.
// This can lead to crashes. Let's try to detangle these subtleties.
MainWindow::instance()->graphics->setPlanState();
DivePlannerPointsModel::instance()->loadFromDive(d);
MainWindow::instance()->graphics->setReplot(true);
MainWindow::instance()->graphics->plotDive(current_dive, true);
MainWindow::instance()->graphics->setProfileState();
}
// This function gets called if a field gets updated by an undo command.
// Refresh the corresponding UI field.
void MainTab::divesChanged(const QVector<dive *> &dives, DiveField field)
@ -316,7 +304,7 @@ void MainTab::divesChanged(const QVector<dive *> &dives, DiveField field)
// If duration or depth changed, the profile needs to be replotted
if (field.duration || field.depth)
profileFromDive(current_dive);
MainWindow::instance()->graphics->plotDive(current_dive, true);
}
void MainTab::diveSiteEdited(dive_site *ds, int)