Dive pictures: Don't plot pictures twice when changing current dive

In MainWindow::current_dive_changed() first plotDive() is called,
which replots all the pictures by calling plotPictures(). This
is pointess, because it plots the pictures of the previous dive.

Then, updateDiveInfo() is called, which resets the dive pictures
and automatically replots them. Thus, switching between dives
both with hundreds of pictures is way slower than necessary.

Switching the plotDive() and updateDiveInfo() calls doesn't work.
The reason is not 100% clear, but it doesn't make sense to plot
pictures of the new dive as long as the profile still shows the
old dive anyway.

As a quick-fix, add a flag to plotDive(), which tells the function
to clear the pictures list instead of redrawing it.
Ultimately, plotDive() should probably be split in two functions.
One for the callers who update the pictures themselves and one
for the others.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2018-05-16 15:25:57 +02:00 committed by Dirk Hohndel
parent f54268e527
commit 45395fd466
4 changed files with 11 additions and 11 deletions

View file

@ -357,7 +357,7 @@ void ProfileWidget2::replot(struct dive *d)
if (!replotEnabled)
return;
dataModel->clear();
plotDive(d, true);
plotDive(d, true, false);
}
void ProfileWidget2::createPPGas(PartialPressureGasItem *item, int verticalColumn, color_index_t color, color_index_t colorAlert,
@ -526,7 +526,7 @@ void ProfileWidget2::resetZoom()
}
// Currently just one dive, but the plan is to enable All of the selected dives.
void ProfileWidget2::plotDive(struct dive *d, bool force)
void ProfileWidget2::plotDive(struct dive *d, bool force, bool doClearPictures)
{
static bool firstCall = true;
#ifndef SUBSURFACE_MOBILE
@ -785,7 +785,7 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
DivePlannerPointsModel *model = DivePlannerPointsModel::instance();
model->deleteTemporaryPlan();
}
if (printMode)
if (doClearPictures)
clearPictures();
else
plotPictures();
@ -1525,7 +1525,7 @@ void ProfileWidget2::deleteCurrentDC()
delete_current_divecomputer();
mark_divelist_changed(true);
// we need to force it since it's likely the same dive and same dc_number - but that's a different dive computer now
plotDive(0, true);
plotDive(0, true, false);
emit refreshDisplay(true);
}