mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 08:08:42 +00:00
New Cyclist set first CP SEGV fix
When setting up the CP for a new cyclist the code for inserting ranges called setCP with an unitialised range number variable. This fix sets it to 0 for the very first range. Also fixed the indentation of the code around the fix to make it easier to follow.
This commit is contained in:
committed by
Sean Rhea
parent
feb111a4ff
commit
d1d2037883
@@ -801,25 +801,27 @@ int Zones::insertRangeAtDate(QDate date, int cp) {
|
||||
assert(date.isValid());
|
||||
int rnum;
|
||||
|
||||
if (ranges.empty())
|
||||
addZoneRange();
|
||||
if (ranges.empty()) {
|
||||
addZoneRange();
|
||||
rnum = 0;
|
||||
}
|
||||
else {
|
||||
rnum = whichRange(date);
|
||||
assert(rnum >= 0);
|
||||
QDate date1 = getStartDate(rnum);
|
||||
rnum = whichRange(date);
|
||||
assert(rnum >= 0);
|
||||
QDate date1 = getStartDate(rnum);
|
||||
|
||||
// if the old range has dates before the specified, then truncate the old range
|
||||
// and shift up the existing ranges
|
||||
if (date > date1) {
|
||||
QDate endDate = getEndDate(rnum);
|
||||
setEndDate(rnum, date);
|
||||
ranges.insert(++ rnum, ZoneRange(date, endDate));
|
||||
}
|
||||
// if the old range has dates before the specified, then truncate
|
||||
// the old range and shift up the existing ranges
|
||||
if (date > date1) {
|
||||
QDate endDate = getEndDate(rnum);
|
||||
setEndDate(rnum, date);
|
||||
ranges.insert(++ rnum, ZoneRange(date, endDate));
|
||||
}
|
||||
}
|
||||
|
||||
if (cp > 0) {
|
||||
setCP(rnum, cp);
|
||||
setZonesFromCP(rnum);
|
||||
setCP(rnum, cp);
|
||||
setZonesFromCP(rnum);
|
||||
}
|
||||
|
||||
return rnum;
|
||||
|
||||
Reference in New Issue
Block a user