mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-02-12 06:10:48 +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;
|
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,
|
bool GPIParser::parse(QFile *file, QList<TrackData> &tracks,
|
||||||
QList<RouteData> &routes, QList<Area> &polygons, QVector<Waypoint> &waypoints)
|
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))
|
if (!readFileHeader(stream) || !readGPIHeader(stream, codec))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
while (stream.status() == QDataStream::Ok)
|
if (!readData(stream, codec, waypoints)) {
|
||||||
if (!readEntry(stream, codec, waypoints))
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (!stream.atEnd()) {
|
|
||||||
_errorString = "Invalid/corrupted GPI data";
|
_errorString = "Invalid/corrupted GPI data";
|
||||||
return false;
|
return false;
|
||||||
} else
|
} else
|
||||||
|
@ -17,6 +17,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
bool readFileHeader(QDataStream &stream);
|
bool readFileHeader(QDataStream &stream);
|
||||||
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,
|
bool readEntry(QDataStream &stream, QTextCodec *codec,
|
||||||
QVector<Waypoint> &waypoints);
|
QVector<Waypoint> &waypoints);
|
||||||
void readPOIDatabase(QDataStream &stream, QTextCodec *codec,
|
void readPOIDatabase(QDataStream &stream, QTextCodec *codec,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user