1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-10-06 06:43:22 +02:00

Fixed error handling

This commit is contained in:
Martin Tůma 2019-10-27 16:34:53 +01:00
parent c0c01eef8b
commit e6b205e823
2 changed files with 13 additions and 5 deletions

View File

@ -414,6 +414,16 @@ bool GPIParser::readEntry(QDataStream &stream, QTextCodec *codec,
return true;
}
bool GPIParser::readData(QDataStream &stream, QTextCodec *codec,
QVector<Waypoint> &waypoints)
{
while (stream.status() == QDataStream::Ok)
if (!readEntry(stream, codec, waypoints))
return stream.atEnd();
return false;
}
bool GPIParser::parse(QFile *file, QList<TrackData> &tracks,
QList<RouteData> &routes, QList<Area> &polygons, QVector<Waypoint> &waypoints)
{
@ -428,11 +438,7 @@ bool GPIParser::parse(QFile *file, QList<TrackData> &tracks,
if (!readFileHeader(stream) || !readGPIHeader(stream, codec))
return false;
while (stream.status() == QDataStream::Ok)
if (!readEntry(stream, codec, waypoints))
break;
if (!stream.atEnd()) {
if (!readData(stream, codec, waypoints)) {
_errorString = "Invalid/corrupted GPI data";
return false;
} else

View File

@ -17,6 +17,8 @@ public:
private:
bool readFileHeader(QDataStream &stream);
bool readGPIHeader(QDataStream &stream, QTextCodec *codec);
bool readData(QDataStream &stream, QTextCodec *codec,
QVector<Waypoint> &waypoints);
bool readEntry(QDataStream &stream, QTextCodec *codec,
QVector<Waypoint> &waypoints);
void readPOIDatabase(QDataStream &stream, QTextCodec *codec,