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:
Mark Liversedge
2010-03-22 17:35:29 +00:00
committed by Sean Rhea
parent 4e7e6cfb3a
commit d64fc6ea85
5 changed files with 19 additions and 11 deletions

View File

@@ -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