diff --git a/src/CpintPlot.cpp b/src/CpintPlot.cpp index c033341fb..4507175b3 100644 --- a/src/CpintPlot.cpp +++ b/src/CpintPlot.cpp @@ -117,7 +117,7 @@ update_cpi_file(const cpi_file_info *info, QProgressDialog *progress, QStringList errors; boost::scoped_ptr 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); diff --git a/src/GcRideFile.cpp b/src/GcRideFile.cpp index 5d6e5069b..a97953636 100644 --- a/src/GcRideFile.cpp +++ b/src/GcRideFile.cpp @@ -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"); diff --git a/src/GoogleMapControl.cpp b/src/GoogleMapControl.cpp index 50abab19f..733380a4f 100644 --- a/src/GoogleMapControl.cpp +++ b/src/GoogleMapControl.cpp @@ -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; diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 314d09170..c58cb46e5 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -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 diff --git a/src/PfPvWindow.cpp b/src/PfPvWindow.cpp index a0124f6a1..287740507 100644 --- a/src/PfPvWindow.cpp +++ b/src/PfPvWindow.cpp @@ -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()));