Avoid crash in CP chart when perspective is not set

This was reported at the forum and it is reproducible with
the supplied home-perspectives.xml, it was likely generated
by an older version, but lets get defensive just in case.
This commit is contained in:
Alejandro Martinez
2022-09-05 12:39:08 -03:00
parent cc6738bdf5
commit fbae10f103
2 changed files with 5 additions and 5 deletions

View File

@@ -1075,7 +1075,7 @@ CPPlot::plotTests(RideItem *rideitem)
fs.addFilter(parent->searchBox->isFiltered(), SearchFilterBox::matches(context, parent->searchBox->filter())); // chart settings
fs.addFilter(context->isfiltered, context->filters);
fs.addFilter(context->ishomefiltered, context->homeFilters);
fs.addFilter(parent->myPerspective->isFiltered(), parent->myPerspective->filterlist(DateRange(startDate,endDate)));
if (parent->myPerspective) fs.addFilter(parent->myPerspective->isFiltered(), parent->myPerspective->filterlist(DateRange(startDate,endDate)));
Specification spec;
spec.setFilterSet(fs);
spec.setDateRange(DateRange(startDate, endDate));
@@ -1206,8 +1206,8 @@ CPPlot::plotBests(RideItem *rideItem)
// but only if rangemode (aka on trends)
if (rangemode) {
bestsCache = new RideFileCache(context, startDate, endDate,
isFiltered||parent->myPerspective->isFiltered(),
files + (parent->myPerspective->isFiltered() ? parent->myPerspective->filterlist(DateRange(startDate,endDate)) : QStringList()),
isFiltered || (parent->myPerspective && parent->myPerspective->isFiltered()),
files + ((parent->myPerspective && parent->myPerspective->isFiltered()) ? parent->myPerspective->filterlist(DateRange(startDate,endDate)) : QStringList()),
rangemode, rideItem);
} else {
bestsCache = new RideFileCache(context, startDate, endDate, isFiltered, files, rangemode, rideItem);
@@ -1771,7 +1771,7 @@ CPPlot::plotEfforts()
FilterSet fs; // apply filters when selecting intervals
fs.addFilter(context->isfiltered, context->filters);
fs.addFilter(context->ishomefiltered, context->homeFilters);
fs.addFilter(parent->myPerspective->isFiltered(), parent->myPerspective->filterlist(DateRange(startDate,endDate)));
if (parent->myPerspective) fs.addFilter(parent->myPerspective->isFiltered(), parent->myPerspective->filterlist(DateRange(startDate,endDate)));
Specification spec;
spec.setFilterSet(fs);
spec.setDateRange(DateRange(startDate, endDate));

View File

@@ -1757,7 +1757,7 @@ CriticalPowerWindow::dateRangeChanged(DateRange dateRange)
fs.addFilter(searchBox->isFiltered(), SearchFilterBox::matches(context, filter()));
fs.addFilter(context->isfiltered, context->filters);
fs.addFilter(context->ishomefiltered, context->homeFilters);
fs.addFilter(myPerspective->isFiltered(), myPerspective->filterlist(dateRange));
if (myPerspective) fs.addFilter(myPerspective->isFiltered(), myPerspective->filterlist(dateRange));
int nActivities, nRides, nRuns, nSwims;
QString sport;
context->athlete->rideCache->getRideTypeCounts(