From a4d91ef17abdc2f1fa16643c5e97358f14edd765 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sat, 27 Nov 2021 10:41:39 +0100 Subject: [PATCH] Added workaround for broken FIT files exported by Strava Fixes #410 --- src/data/fitparser.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/data/fitparser.cpp b/src/data/fitparser.cpp index d8b252ab..02060b9e 100644 --- a/src/data/fitparser.cpp +++ b/src/data/fitparser.cpp @@ -223,6 +223,22 @@ bool FITParser::readField(CTX &ctx, Field *field, QVariant &val, bool &valid) case 0: // enum VAL(quint8, 0xffU); break; + case 3: + case 0x83: // sint16 + VAL(qint16, 0x7fffU); + break; + case 4: + case 0x84: // uint16 + VAL(quint16, 0xffffU); + break; + case 5: + case 0x85: // sint32 + VAL(qint32, 0x7fffffffU); + break; + case 6: + case 0x86: // uint32 + VAL(quint32, 0xffffffffU); + break; case 7: // UTF8 nul terminated string {QByteArray ba(ctx.file->read(field->size)); ctx.len -= field->size; @@ -230,18 +246,6 @@ bool FITParser::readField(CTX &ctx, Field *field, QVariant &val, bool &valid) val = ret ? ba : QString(); valid = !ba.isEmpty();} break; - case 0x83: // sint16 - VAL(qint16, 0x7fffU); - break; - case 0x84: // uint16 - VAL(quint16, 0xffffU); - break; - case 0x85: // sint32 - VAL(qint32, 0x7fffffffU); - break; - case 0x86: // uint32 - VAL(quint32, 0xffffffffU); - break; default: ret = skipValue(ctx, field->size); valid = false;