From 8c995a53394236ed39724c028d47e9227f74a10a Mon Sep 17 00:00:00 2001 From: Ale Martinez Date: Sat, 11 May 2019 11:32:04 -0300 Subject: [PATCH] HRV import from text file - fix discard of last line Fixes #3094 --- src/FileIO/TxtRideFile.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/FileIO/TxtRideFile.cpp b/src/FileIO/TxtRideFile.cpp index 54a39e13b..f6f9443b2 100644 --- a/src/FileIO/TxtRideFile.cpp +++ b/src/FileIO/TxtRideFile.cpp @@ -530,6 +530,13 @@ RideFile *TxtFileReader::openRideFile(QFile &file, QStringList &errors, QListsetDeviceType("R-R"); @@ -542,9 +549,12 @@ RideFile *TxtFileReader::openRideFile(QFile &file, QStringList &errors, QListunitname << "msecs"; double secs = 0.0; - do { + while (!is.atEnd()) { double rr; + line = is.readLine(); + tokens = line.split(QRegExp("[ \t]"), QString::SkipEmptyParts); + if (rrType == RR_Type2 && tokens.count() > 1) rr = tokens[1].toDouble(); else if (rrType == RR_Type1 && tokens.count() > 0) rr = tokens[0].toDouble(); else continue; // skip blank or incomplete lines @@ -562,10 +572,7 @@ RideFile *TxtFileReader::openRideFile(QFile &file, QStringList &errors, QListdatapoints.append(p); secs += rr; - - line = in.readLine(); - tokens = line.split(QRegExp("[ \t]"), QString::SkipEmptyParts); - } while (!in.atEnd()); + } if (hrvXdata->datapoints.count()>0) rideFile->addXData("HRV", hrvXdata);