mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-01-31 09:05:14 +01:00
Fixed error handling
This commit is contained in:
parent
c0c01eef8b
commit
e6b205e823
@ -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
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user