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

Fixed broken GPI files encoding handling

This commit is contained in:
Martin Tůma 2019-11-02 09:54:11 +01:00
parent b2ca97b836
commit 2ba78545ef
2 changed files with 7 additions and 7 deletions

View File

@ -362,7 +362,7 @@ bool GPIParser::readFileHeader(QDataStream &stream, quint32 &ebs)
return true;
}
bool GPIParser::readGPIHeader(QDataStream &stream, QTextCodec *codec)
bool GPIParser::readGPIHeader(QDataStream &stream, QTextCodec **codec)
{
RecordHeader rh;
char m1[6], m2[2];
@ -377,15 +377,15 @@ bool GPIParser::readGPIHeader(QDataStream &stream, QTextCodec *codec)
ds = sizeof(m1) + sizeof(m2) + 4;
if (codepage == 65001)
codec = QTextCodec::codecForName("UTF-8");
*codec = QTextCodec::codecForName("UTF-8");
else if (codepage == 0)
codec = 0;
*codec = 0;
else
codec = QTextCodec::codecForName(QString("CP%1").arg(codepage)
*codec = QTextCodec::codecForName(QString("CP%1").arg(codepage)
.toLatin1());
if (s2 & 0x10)
ds += readFileDataRecord(stream, codec);
ds += readFileDataRecord(stream, *codec);
if (stream.status() != QDataStream::Ok || ds != rh.size) {
_errorString = "Invalid GPI header";
@ -461,7 +461,7 @@ bool GPIParser::parse(QFile *file, QList<TrackData> &tracks,
stream.setByteOrder(QDataStream::LittleEndian);
if (!readFileHeader(stream, ebs) || !readGPIHeader(stream, codec))
if (!readFileHeader(stream, ebs) || !readGPIHeader(stream, &codec))
return false;
if (ebs) {

View File

@ -16,7 +16,7 @@ public:
private:
bool readFileHeader(QDataStream &stream, quint32 &ebs);
bool readGPIHeader(QDataStream &stream, QTextCodec *codec);
bool readGPIHeader(QDataStream &stream, QTextCodec **codec);
bool readData(QDataStream &stream, QTextCodec *codec,
QVector<Waypoint> &waypoints);
bool readEntry(QDataStream &stream, QTextCodec *codec,