Permalink
Browse files

Fix Aerolab crash on no ride selected

.. when no ride available or last ride deleted lots of crashes. None
   of the slot functions check for null, so lots of crashes.
  • Loading branch information...
liversedge committed Oct 4, 2018
1 parent 475288d commit e264405302fea2837b8cecd30b51fcf69e05191d
Showing with 11 additions and 8 deletions.
  1. +7 −2 src/Charts/Aerolab.cpp
  2. +4 −6 src/Charts/AerolabWindow.cpp
View
@@ -91,7 +91,7 @@ IntervalItem *IntervalAerolabData::intervalNum
int number
) const
{
if (number >= 0 && aerolab->rideItem->intervalsSelected().count() > number)
if (aerolab->rideItem && number >= 0 && aerolab->rideItem->intervalsSelected().count() > number)
return aerolab->rideItem->intervalsSelected().at(number);
return NULL;
@@ -102,7 +102,8 @@ IntervalItem *IntervalAerolabData::intervalNum
// ------------------------------------------------------------------------------------------------------------
int IntervalAerolabData::intervalCount() const
{
return aerolab->rideItem->intervalsSelected().count();
if (aerolab->rideItem) return aerolab->rideItem->intervalsSelected().count();
return 0;
}
/*
* INTERVAL HIGHLIGHTING CURVE
@@ -285,6 +286,8 @@ Aerolab::setData(RideItem *_rideItem, bool new_zoom) {
double small_number = 0.00001;
rideItem = _rideItem;
if (rideItem == NULL || rideItem->ride() == NULL) return;
RideFile *ride = rideItem->ride();
veArray.clear();
@@ -770,6 +773,8 @@ QString Aerolab::estimateCdACrr(RideItem *rideItem)
// HARD-CODED DATA: p1->kph
const double vfactor = 3.600;
const double g = KG_FORCE_PER_METER;
if (rideItem == NULL || rideItem->ride() == NULL) return (tr("No ride selected"));
RideFile *ride = rideItem->ride();
QString errMsg;
@@ -369,9 +369,8 @@ AerolabWindow::configChanged(qint32)
void
AerolabWindow::rideSelected() {
if (!amVisible()) return;
RideItem *ride = myRideItem;
if (!amVisible() || ride == NULL || ride->ride() == NULL) return;
commentEdit->setText("");
@@ -661,10 +660,7 @@ AerolabWindow::zoomInterval(IntervalItem *which) {
void AerolabWindow::intervalSelected()
{
RideItem *ride = myRideItem;
if ( !ride )
{
return;
}
if (!amVisible() || ride == NULL || ride->ride() == NULL) return;
// set the elevation data
refresh(ride, true);
@@ -701,6 +697,8 @@ void AerolabWindow::saveParametersInRide()
bool AerolabWindow::hasNewParametersInRide()
{
if (rideItem() == NULL || rideItem()->ride() == NULL) return false;
bool newValues = false;
if (rideItem()->ride()->getTag("Total Weight", "0").toDouble() != aerolab->getTotalMass()) {

0 comments on commit e264405

Please sign in to comment.