diff --git a/src/data/pltparser.cpp b/src/data/pltparser.cpp index abe957f3..abaceda9 100644 --- a/src/data/pltparser.cpp +++ b/src/data/pltparser.cpp @@ -55,22 +55,28 @@ bool PLTParser::parse(QFile *file, QList &tracks, Trackpoint tp(gcs->toWGS84(Coordinates(lon, lat))); if (list.size() >= 4) { - double elevation = list.at(3).trimmed().toDouble(&res); - if (!res) { - _errorString = "Invalid elevation"; - return false; + QByteArray field(list.at(3).trimmed()); + if (!field.isEmpty()) { + double elevation = field.toDouble(&res); + if (!res) { + _errorString = "Invalid elevation"; + return false; + } + if (elevation != -777) + tp.setElevation(elevation * 0.3048); } - if (elevation != -777) - tp.setElevation(elevation * 0.3048); } if (list.size() >= 5) { - double date = list.at(4).trimmed().toDouble(&res); - if (!res) { - _errorString = "Invalid date"; - return false; + QByteArray field(list.at(4).trimmed()); + if (!field.isEmpty()) { + double date = field.toDouble(&res); + if (!res) { + _errorString = "Invalid date"; + return false; + } + tp.setTimestamp(QDateTime::fromMSecsSinceEpoch( + Date::delphi2unixMS(date))); } - tp.setTimestamp(QDateTime::fromMSecsSinceEpoch( - Date::delphi2unixMS(date))); } track.append(tp); diff --git a/src/data/rteparser.cpp b/src/data/rteparser.cpp index 36c6b7cc..691a1ef3 100644 --- a/src/data/rteparser.cpp +++ b/src/data/rteparser.cpp @@ -68,17 +68,21 @@ bool RTEParser::parse(QFile *file, QList &tracks, if (!name.isEmpty()) wp.setName(name); if (list.size() >= 8) { - double date = list.at(7).trimmed().toDouble(&res); - if (!res) { - _errorString = "Invalid date"; - return false; + QByteArray field(list.at(7).trimmed()); + if (!field.isEmpty()) { + double date = field.toDouble(&res); + if (!res) { + _errorString = "Invalid date"; + return false; + } + wp.setTimestamp(QDateTime::fromMSecsSinceEpoch( + Date::delphi2unixMS(date))); } - wp.setTimestamp(QDateTime::fromMSecsSinceEpoch( - Date::delphi2unixMS(date))); } if (list.size() >= 14) { QString desc(list.at(13).trimmed().replace('\xD1', ',')); - wp.setDescription(desc); + if (!desc.isEmpty()) + wp.setDescription(desc); } routes.last().append(wp); diff --git a/src/data/wptparser.cpp b/src/data/wptparser.cpp index f07ca92e..8697c521 100644 --- a/src/data/wptparser.cpp +++ b/src/data/wptparser.cpp @@ -51,26 +51,33 @@ bool WPTParser::parse(QFile *file, QList &tracks, if (!name.isEmpty()) wp.setName(name); if (list.size() >= 5) { - double date = list.at(4).trimmed().toDouble(&res); - if (!res) { - _errorString = "Invalid date"; - return false; + QByteArray field(list.at(4).trimmed()); + if (!field.isEmpty()) { + double date = field.toDouble(&res); + if (!res) { + _errorString = "Invalid date"; + return false; + } + wp.setTimestamp(QDateTime::fromMSecsSinceEpoch( + Date::delphi2unixMS(date))); } - wp.setTimestamp(QDateTime::fromMSecsSinceEpoch( - Date::delphi2unixMS(date))); } if (list.size() >= 11) { QString desc(list.at(10).trimmed().replace('\xD1', ',')); if (!desc.isEmpty()) wp.setDescription(desc); - } if (list.size() >= 15) { - double elevation = list.at(14).trimmed().toDouble(&res); - if (!res) { - _errorString = "Invalid elevation"; - return false; + } + if (list.size() >= 15) { + QByteArray field(list.at(14).trimmed()); + if (!field.isEmpty()) { + double elevation = list.at(14).trimmed().toDouble(&res); + if (!res) { + _errorString = "Invalid elevation"; + return false; + } + if (elevation != -777) + wp.setElevation(elevation * 0.3048); } - if (elevation != -777) - wp.setElevation(elevation * 0.3048); } waypoints.append(wp);