From b457fc430c550221a37c183d4189a30f585ea373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Thu, 14 Sep 2017 20:18:34 +0200 Subject: [PATCH] Fixed broken parsing of TCX files with heart rate data --- src/tcxparser.cpp | 12 +++++++++++- src/tcxparser.h | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/tcxparser.cpp b/src/tcxparser.cpp index 5a3c53c6..c9abfb1b 100644 --- a/src/tcxparser.cpp +++ b/src/tcxparser.cpp @@ -56,6 +56,16 @@ Coordinates TCXParser::position() return pos; } +void TCXParser::heartRateBpm(Trackpoint &trackpoint) +{ + while (_reader.readNextStartElement()) { + if (_reader.name() == "Value") + trackpoint.setHeartRate(number()); + else + _reader.skipCurrentElement(); + } +} + void TCXParser::extensions(Trackpoint &trackpoint) { while (_reader.readNextStartElement()) { @@ -78,7 +88,7 @@ void TCXParser::trackpointData(Trackpoint &trackpoint) else if (_reader.name() == "Time") trackpoint.setTimestamp(time()); else if (_reader.name() == "HeartRateBpm") - trackpoint.setHeartRate(number()); + heartRateBpm(trackpoint); else if (_reader.name() == "Cadence") trackpoint.setCadence(number()); else if (_reader.name() == "Extensions") diff --git a/src/tcxparser.h b/src/tcxparser.h index 8a001d6e..b1490c65 100644 --- a/src/tcxparser.h +++ b/src/tcxparser.h @@ -26,6 +26,7 @@ private: void trackpointData(Trackpoint &trackpoint); void waypointData(Waypoint &waypoint); void extensions(Trackpoint &trackpoint); + void heartRateBpm(Trackpoint &trackpoint); Coordinates position(); qreal number(); QDateTime time();