mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
zones ptr is never null
This commit is contained in:
@@ -111,7 +111,7 @@ class RelativeIntensity : public RideMetric {
|
||||
double value(bool) const { return reli; }
|
||||
void compute(const RideFile *, const Zones *zones, int zoneRange,
|
||||
const QHash<QString,RideMetric*> &deps) {
|
||||
if (zones) {
|
||||
if (zones && zoneRange >= 0) {
|
||||
assert(deps.contains("skiba_xpower"));
|
||||
XPower *xp = dynamic_cast<XPower*>(deps.value("skiba_xpower"));
|
||||
assert(xp);
|
||||
@@ -145,7 +145,7 @@ class BikeScore : public RideMetric {
|
||||
double value(bool) const { return score; }
|
||||
void compute(const RideFile *ride, const Zones *zones, int zoneRange,
|
||||
const QHash<QString,RideMetric*> &deps) {
|
||||
if (!zones)
|
||||
if (!zones || zoneRange < 0)
|
||||
return;
|
||||
if (ride->deviceType() == QString("Manual CSV")) {
|
||||
// manual entry, use BS from dataPoints
|
||||
|
||||
@@ -45,7 +45,7 @@ class DanielsPoints : public RideMetric {
|
||||
double value(bool) const { return score; }
|
||||
void compute(const RideFile *ride, const Zones *zones,
|
||||
int zoneRange, const QHash<QString,RideMetric*> &) {
|
||||
if (!zones)
|
||||
if (!zones || zoneRange < 0)
|
||||
return;
|
||||
|
||||
if (ride->deviceType() == QString("Manual CSV")) {
|
||||
|
||||
@@ -86,7 +86,7 @@ MainWindow::parseRideFileName(const QString &name, QString *notesFileName, QDate
|
||||
|
||||
MainWindow::MainWindow(const QDir &home) :
|
||||
home(home),
|
||||
zones(NULL), currentNotesChanged(false),
|
||||
zones(new Zones), currentNotesChanged(false),
|
||||
ride(NULL)
|
||||
{
|
||||
settings = GetApplicationSettings();
|
||||
@@ -102,12 +102,10 @@ MainWindow::MainWindow(const QDir &home) :
|
||||
|
||||
QFile zonesFile(home.absolutePath() + "/power.zones");
|
||||
if (zonesFile.exists()) {
|
||||
zones = new Zones();
|
||||
if (!zones->read(zonesFile)) {
|
||||
QMessageBox::critical(this, tr("Zones File Error"),
|
||||
zones->errorString());
|
||||
delete zones;
|
||||
zones = NULL;
|
||||
zones->clear();
|
||||
}
|
||||
else if (! zones->warningString().isEmpty())
|
||||
QMessageBox::warning(this, tr("Reading Zones File"), zones->warningString());
|
||||
@@ -803,11 +801,6 @@ MainWindow::splitterMoved()
|
||||
void
|
||||
MainWindow::setCriticalPower(int cp)
|
||||
{
|
||||
if (zones == NULL)
|
||||
// set up new zones
|
||||
zones = new Zones();
|
||||
|
||||
|
||||
// determine in which range to write the value: use the range associated with the presently selected ride
|
||||
int range;
|
||||
if (ride)
|
||||
|
||||
@@ -442,7 +442,7 @@ int Zones::whichRange(const QDate &date) const
|
||||
((date < range.end) || (range.end.isNull())))
|
||||
return rnum;
|
||||
}
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int Zones::numZones(int rnum) const
|
||||
|
||||
@@ -59,6 +59,12 @@ class Zones : public QObject
|
||||
public:
|
||||
Zones() : defaults_from_user(false) {}
|
||||
|
||||
void clear() {
|
||||
ranges.clear();
|
||||
err = warning = "";
|
||||
defaults_from_user = false;
|
||||
}
|
||||
|
||||
void addZoneRange(QDate _start, QDate _end, int _cp);
|
||||
void addZoneRange();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user