From 2ba78545eff5eff75c6fdbcbeae2e062bf9b1c70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sat, 2 Nov 2019 09:54:11 +0100 Subject: [PATCH] Fixed broken GPI files encoding handling --- src/data/gpiparser.cpp | 12 ++++++------ src/data/gpiparser.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/data/gpiparser.cpp b/src/data/gpiparser.cpp index fc91e0e2..53c1c367 100644 --- a/src/data/gpiparser.cpp +++ b/src/data/gpiparser.cpp @@ -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 &tracks, stream.setByteOrder(QDataStream::LittleEndian); - if (!readFileHeader(stream, ebs) || !readGPIHeader(stream, codec)) + if (!readFileHeader(stream, ebs) || !readGPIHeader(stream, &codec)) return false; if (ebs) { diff --git a/src/data/gpiparser.h b/src/data/gpiparser.h index d6bb61a3..24192f72 100644 --- a/src/data/gpiparser.h +++ b/src/data/gpiparser.h @@ -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 &waypoints); bool readEntry(QDataStream &stream, QTextCodec *codec,