diff --git a/core/namecmp.h b/core/namecmp.h new file mode 100644 index 000000000..f0781bb50 --- /dev/null +++ b/core/namecmp.h @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0 +#ifndef NAMECMP_H +#define NAMECMP_H + +#ifdef __cplusplus + +#include + +// this is annoying Qt5 / Qt6 incompatibility where we can't compare against string literals anymore +static inline int nameCmp(QXmlStreamReader &r, const char * cs) +{ + return r.name().compare(QLatin1String(cs)); +} + +#endif +#endif // NAMECMP_H diff --git a/core/parse-gpx.cpp b/core/parse-gpx.cpp index 11e332091..67feae3c5 100644 --- a/core/parse-gpx.cpp +++ b/core/parse-gpx.cpp @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include "core/parse-gpx.h" #include "core/subsurface-time.h" +#include "core/namecmp.h" #include #include @@ -43,7 +44,7 @@ int getCoordsFromGPXFile(struct dive_coords *coords, QString fileName) while (!gpxReader.atEnd()) { gpxReader.readNext(); if (gpxReader.isStartElement()) { - if (gpxReader.name() == "trkpt") { + if (nameCmp(gpxReader, "trkpt") == 0) { trkpt_found = true; line++; foreach (const QXmlStreamAttribute &attr, gpxReader.attributes()) { @@ -53,7 +54,7 @@ int getCoordsFromGPXFile(struct dive_coords *coords, QString fileName) lon = attr.value().toString().toDouble(); } } - if (gpxReader.name() == "time" && trkpt_found) { // Ignore the