mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-16 09:29:55 +00:00
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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user