1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-28 05:34:47 +01:00

Fixed crash on empty segment

Fixes #239
This commit is contained in:
Martin Tůma 2019-10-29 09:10:32 +01:00
parent 29147e1b8b
commit 10d2fe4431

View File

@ -74,17 +74,19 @@ Track::Track(const TrackData &data) : _data(data), _pause(0)
for (int i = 0; i < _data.size(); i++) {
const SegmentData &sd = _data.at(i);
_segments.append(Segment());
if (sd.isEmpty())
continue;
// precompute distances, times, speeds and acceleration
QVector<qreal> acceleration;
_segments.append(Segment());
Segment &seg = _segments.last();
seg.distance.append(i ? _segments.at(i-1).distance.last() : 0);
seg.time.append(i ? _segments.at(i-1).time.last() :
seg.distance.append(i && !_segments.at(i-1).distance.isEmpty()
? _segments.at(i-1).distance.last() : 0);
seg.time.append(i && !_segments.at(i-1).time.isEmpty()
? _segments.at(i-1).time.last() :
sd.first().hasTimestamp() ? 0 : NAN);
seg.speed.append(sd.first().hasTimestamp() ? 0 : NAN);
acceleration.append(sd.first().hasTimestamp() ? 0 : NAN);