mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-14 00:28:42 +00:00
NULL/Empty ride checks
RideItem or RideFile or dataPoints() may be null or empty. This is especially true of manual ridefiles. This patch adds some checks for this situation and acts accordingly. Additionally, the disable/enable of tabs depending upon ridefile type has been adjusted to also include files with not dataPoints.
This commit is contained in:
committed by
Sean Rhea
parent
4e7e6cfb3a
commit
d64fc6ea85
@@ -117,7 +117,7 @@ update_cpi_file(const cpi_file_info *info, QProgressDialog *progress,
|
||||
QStringList errors;
|
||||
boost::scoped_ptr<RideFile> rideFile(
|
||||
RideFileFactory::instance().openRideFile(file, errors));
|
||||
if (! rideFile)
|
||||
if (!rideFile || rideFile->dataPoints().isEmpty())
|
||||
return;
|
||||
cpint_data data;
|
||||
data.rec_int_ms = (int) round(rideFile->recIntSecs() * 1000.0);
|
||||
|
||||
@@ -86,10 +86,7 @@ GcFileReader::openRideFile(QFile &file, QStringList &errors) const
|
||||
int interval = 0;
|
||||
|
||||
QDomElement samples = root.firstChildElement("samples");
|
||||
if (samples.isNull()) {
|
||||
errors << "no sample section in ride file";
|
||||
return NULL;
|
||||
}
|
||||
if (samples.isNull()) return rideFile; // manual file will have no samples
|
||||
|
||||
bool recIntSet = false;
|
||||
for (QDomElement sample = samples.firstChildElement("sample");
|
||||
|
||||
@@ -176,6 +176,9 @@ GoogleMapControl::rideSelected()
|
||||
rideData.clear();
|
||||
double prevLon = 0;
|
||||
double prevLat = 0;
|
||||
|
||||
if (ride == NULL || ride->ride() == NULL) return;
|
||||
|
||||
foreach(RideFilePoint *rfp,ride->ride()->dataPoints())
|
||||
{
|
||||
RideFilePoint curRfp = *rfp;
|
||||
|
||||
@@ -810,11 +810,18 @@ MainWindow::rideTreeWidgetSelectionChanged()
|
||||
// turn off tabs that don't make sense for manual file entry
|
||||
int histIndex = tabWidget->indexOf(histogramWindow);
|
||||
int pfpvIndex = tabWidget->indexOf(pfPvWindow);
|
||||
bool enabled = !ride->ride() || ride->ride()->deviceType() != QString("Manual CSV");
|
||||
if (histIndex >= 0)
|
||||
tabWidget->setTabEnabled(histIndex, enabled);
|
||||
if (pfpvIndex >= 0)
|
||||
tabWidget->setTabEnabled(pfpvIndex, enabled);
|
||||
int plotIndex = tabWidget->indexOf(allPlotWindow);
|
||||
int modelIndex = tabWidget->indexOf(modelWindow);
|
||||
int mapIndex = tabWidget->indexOf(googleMap);
|
||||
bool enabled = (!ride->ride() || ride->ride()->deviceType() != QString("Manual CSV"))
|
||||
&&
|
||||
(!ride->ride() ||!ride->ride()->dataPoints().isEmpty());
|
||||
|
||||
if (histIndex >= 0) tabWidget->setTabEnabled(histIndex, enabled);
|
||||
if (pfpvIndex >= 0) tabWidget->setTabEnabled(pfpvIndex, enabled);
|
||||
if (plotIndex >= 0) tabWidget->setTabEnabled(plotIndex, enabled);
|
||||
if (modelIndex >= 0) tabWidget->setTabEnabled(modelIndex, enabled);
|
||||
if (mapIndex >= 0) tabWidget->setTabEnabled(mapIndex, enabled);
|
||||
saveAndOpenNotes();
|
||||
}
|
||||
void
|
||||
|
||||
@@ -91,8 +91,9 @@ PfPvWindow::rideSelected()
|
||||
if (mainWindow->activeTab() != this)
|
||||
return;
|
||||
RideItem *ride = mainWindow->rideItem();
|
||||
if (!ride)
|
||||
if (!ride || !ride->ride())
|
||||
return;
|
||||
|
||||
pfPvPlot->setData(ride);
|
||||
// update the QLabel widget with the CP value set in PfPvPlot::setData()
|
||||
qaCPValue->setText(QString("%1").arg(pfPvPlot->getCP()));
|
||||
|
||||
Reference in New Issue
Block a user