Profile: remove ProfileWidget2::recalcCeiling()

The ProfileWidget2::recalcCeiling() function is used in one place,
namely when an undo-command changes the mode. It recalculates
decompression data and repaints the ceilings and thus avoids a
full profile-redraw.

This is smart, but it becomes problematic when the dive is changed
and the ceiling is recalculated before the profile is redrawn.
The DivePlotDataModel then still has data from the previous dive
but cylinders of the new dive are accessed.

This kind of situation may arise if multiple dive fields are
updated, as for example when replanning a dive.

Currently, this only causes a temporary mis-calculation. When
removing MAX_CYLINDERS this will lead to crashes.

One might attempt to fix the whole data-dependency mess. This
commit goes the cheap route and simply redraws the profile when
the mode is changed. Yes, it is in a way ineffective, but we
do worse things. The ProfileWidget2::recalcCeiling() thus becomes
unused and is removed.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2019-11-01 18:09:03 +01:00 committed by Dirk Hohndel
parent a3a3913e1e
commit ec8e109a1a
3 changed files with 1 additions and 9 deletions

View file

@ -355,7 +355,7 @@ void MainTab::updateNotes(const struct dive *d)
void MainTab::updateMode(struct dive *d)
{
ui.DiveType->setCurrentIndex(get_dive_dc(d, dc_number)->divemode);
MainWindow::instance()->graphics->recalcCeiling();
MainWindow::instance()->graphics->replot();
}
static QDateTime timestampToDateTime(timestamp_t when)

View file

@ -839,13 +839,6 @@ void ProfileWidget2::plotDive(const struct dive *d, bool force, bool doClearPict
#endif
}
void ProfileWidget2::recalcCeiling()
{
#ifndef SUBSURFACE_MOBILE
diveCeiling->recalc();
#endif
}
void ProfileWidget2::dateTimeChanged()
{
emit dateTimeChangedItems();

View file

@ -87,7 +87,6 @@ public:
bool eventFilter(QObject *, QEvent *) override;
void clearHandlers();
#endif
void recalcCeiling();
void setToolTipVisibile(bool visible);
State currentState;
int animSpeed;