Fix Train mode SEGV in Course/Ergo Mode

If you select an erg file then choose ergo/slope
mode in train view the workout plot will crash
when the sidebar is hidden / window resized because
the workout plot is still referencing an ergfile
that has been deleted.

This patch ensures the workout plot is notified that
NO ergfile is selected thus clearing the plot and
also ensuring no reference to the deleted ergfile
remains.
This commit is contained in:
Mark Liversedge
2011-10-02 11:00:20 +01:00
parent ee9cf5aeac
commit 7c36a58db1
2 changed files with 20 additions and 9 deletions

View File

@@ -80,21 +80,21 @@ ErgFilePlot::ErgFilePlot(QList<ErgFilePoint> *data)
void
ErgFilePlot::setData(ErgFile *ergfile)
{
ergFile = ergfile;
// clear the previous marks (if any)
for(int i=0; i<Marks.count(); i++) {
Marks.at(i)->detach();
delete Marks.at(i);
}
Marks.clear();
if (ergfile) {
// set up again
ergFile = ergfile;
//setTitle(ergFile->Name);
courseData = &ergfile->Points;
MaxWatts = ergfile->MaxWatts;
// clear the previous marks (if any)
for(int i=0; i<Marks.count(); i++) {
Marks.at(i)->detach();
delete Marks.at(i);
}
Marks.clear();
for(int i=0; i < ergFile->Laps.count(); i++) {
// Show Lap Number
@@ -116,6 +116,12 @@ ErgFilePlot::setData(ErgFile *ergfile)
// set the axis so we use all the screen estate
if ((*courseData).count()) setAxisScale(xBottom, (double)0, (double)(*courseData).last().x);
} else {
// clear the plot we have nothing selected
MaxWatts = 0;
courseData = NULL;
}
}