Fix JSON reader ignoring open fail

D'oh.

The ridefile reader for JSON files spotted when a file failed
to open but then continued to try and parse it!  Now returns NULL
when fopen fails.

This is particularly relevant when using foreign characters in
a filename passed to fopen(). We need to remove the fopen stuff
and replace if QFile reading to a buffer.
This commit is contained in:
Mark Liversedge
2013-03-12 07:47:58 +00:00
parent ceedada7cf
commit 7e424c88ad

View File

@@ -247,7 +247,8 @@ JsonFileReader::openRideFile(QFile &file, QStringList &errors, QList<RideFile*>*
// JsonRideFilein is the FILE * used by the lexer
JsonRideFilein = fopen(file.fileName().toLatin1(), "r");
if (JsonRideFilein == NULL) {
errors << "unable to open file" + file.fileName();
errors << "unable to open file (locale?)" + file.fileName();
return NULL; // failed to open the file ?
}
// inform the parser/lexer we have a new file
JsonRideFilerestart(JsonRideFilein);