diff --git a/src/data/data.cpp b/src/data/data.cpp index 74432a56..062e7bb6 100644 --- a/src/data/data.cpp +++ b/src/data/data.cpp @@ -121,6 +121,13 @@ Data::Data(const QString &fileName, bool tryUnknown) file.reset(); ++it; } + + qWarning("%s:", qPrintable(fileName)); + for (it = _parsers.find(suffix); it != _parsers.end() + && it.key() == suffix; it++) + qWarning(" %s: line %d: %s", qPrintable(it.key()), + it.value()->errorLine(), qPrintable(it.value()->errorString())); + } else if (tryUnknown) { for (it = _parsers.begin(); it != _parsers.end(); it++) { if (it.value()->parse(&file, trackData, routeData, _polygons, @@ -132,9 +139,9 @@ Data::Data(const QString &fileName, bool tryUnknown) file.reset(); } - qWarning("Error loading data file: %s:", qPrintable(fileName)); + qWarning("%s:", qPrintable(fileName)); for (it = _parsers.begin(); it != _parsers.end(); it++) - qWarning("%s: line %d: %s", qPrintable(it.key()), + qWarning(" %s: line %d: %s", qPrintable(it.key()), it.value()->errorLine(), qPrintable(it.value()->errorString())); _errorLine = 0; diff --git a/src/map/maplist.cpp b/src/map/maplist.cpp index 12477cdb..529dd39b 100644 --- a/src/map/maplist.cpp +++ b/src/map/maplist.cpp @@ -62,37 +62,36 @@ Map *MapList::loadFile(const QString &path, const Projection &proj, bool *isDir) QFileInfo fi(path); QString suffix(fi.suffix().toLower()); Map *map = 0; + QStringList errors; if ((it = _parsers.find(suffix)) != _parsers.end()) { while (it != _parsers.end() && it.key() == suffix) { delete map; map = it.value()(path, proj, isDir); if (map->isValid()) - break; - + return map; + else + errors.append(it.key() + ": " + map->errorString()); ++it; } - } else { - QStringList errors; + } else { for (it = _parsers.begin(); it != _parsers.end(); it++) { map = it.value()(path, proj, isDir); if (map->isValid()) - break; + return map; else { errors.append(it.key() + ": " + map->errorString()); delete map; map = 0; } } - - if (!map) { - qWarning("Error loading map file: %s:", qPrintable(path)); - for (int i = 0; i < errors.size(); i++) - qWarning("%s", qPrintable(errors.at(i))); - } } + qWarning("%s:", qPrintable(path)); + for (int i = 0; i < errors.size(); i++) + qWarning(" %s", qPrintable(errors.at(i))); + return map ? map : new InvalidMap(path, "Unknown file format"); } diff --git a/src/map/wldfile.cpp b/src/map/wldfile.cpp index 04dfd978..4e38b34f 100644 --- a/src/map/wldfile.cpp +++ b/src/map/wldfile.cpp @@ -16,7 +16,7 @@ WLDFile::WLDFile(const QString &fileName) QByteArray line(file.readLine(128).trimmed()); val[i] = line.toDouble(&ok); if (!ok) { - _errorString = line + ": invalid parameter"; + _errorString = QString("Parse error on line %1").arg(i+1); return; } }