mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-04-15 05:32:21 +00:00
Fix CSV parser and more checks for NULL ride
The CSV ride parser now checks for empty rides and returns a NULL ride if there are no samples. In addition, the rideEditor tries to set editorData even if the ride is NULL. Lastly, the RideItem code for lazy reads of RideFile data didn't check for NULL values (!).
This commit is contained in:
@@ -296,6 +296,13 @@ RideFile *CsvFileReader::openRideFile(QFile &file, QStringList &errors) const
|
||||
qWarning("Failed to set start time");
|
||||
}
|
||||
}
|
||||
return rideFile;
|
||||
}
|
||||
|
||||
// did we actually read any samples?
|
||||
if (rideFile->dataPoints().count() > 0) {
|
||||
return rideFile;
|
||||
} else {
|
||||
errors << "No samples present.";
|
||||
delete rideFile;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1082,7 +1082,7 @@ void
|
||||
RideEditor::rideSelected()
|
||||
{
|
||||
RideItem *current = main->rideItem();
|
||||
if (!current) return;
|
||||
if (!current || !current->ride()) return;
|
||||
|
||||
ride = current;
|
||||
|
||||
|
||||
@@ -46,6 +46,8 @@ RideFile *RideItem::ride()
|
||||
// open the ride file
|
||||
QFile file(path + "/" + fileName);
|
||||
ride_ = RideFileFactory::instance().openRideFile(file, errors_);
|
||||
if (ride_ == NULL) return NULL; // failed to read ride
|
||||
|
||||
setDirty(false); // we're gonna use on-disk so by
|
||||
// definition it is clean - but do it *after*
|
||||
// we read the file since it will almost
|
||||
|
||||
Reference in New Issue
Block a user