summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2016-10-05 09:12:31 +0200
committerMarc Mutz <marc.mutz@kdab.com>2016-10-05 19:57:55 +0000
commit8c4b9eda3383a469ae47b8dedbf5093c5b4e10df (patch)
treefa71103d7d5850076b0f5ed9a95e4fbb3fe8e5c2
parent250368c565ef9a40e3c0ebb646e45f04b5200e01 (diff)
GLTFIO: check return value of QFile::open()
We checked that the file exists prior to opening it, but it could still be unreadable (due to permissions, e.g.), so check with QFile::open() and emit QFile::errorString() in case it goes wrong. Coverity-Id: 161328 Change-Id: I3489488023bb697d6cb9eee6be07c0edd923c478 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
-rw-r--r--src/plugins/sceneparsers/gltf/gltfparser.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/plugins/sceneparsers/gltf/gltfparser.cpp b/src/plugins/sceneparsers/gltf/gltfparser.cpp
index 6bfca2b55..e42ebb510 100644
--- a/src/plugins/sceneparsers/gltf/gltfparser.cpp
+++ b/src/plugins/sceneparsers/gltf/gltfparser.cpp
@@ -196,13 +196,11 @@ bool GLTFParser::setJSON(const QJsonDocument &json )
void GLTFParser::setSource(const QUrl &source)
{
const QString path = QUrlHelper::urlToLocalFileOrQrc(source);
- QFileInfo finfo(path);
- if (!finfo.exists()) {
- qCWarning(GLTFParserLog) << "missing file:" << path;
+ QFile f(path);
+ if (Q_UNLIKELY(!f.open(QIODevice::ReadOnly))) {
+ qCWarning(GLTFParserLog) << "cannot open " << path << ": " << f.errorString();
return;
}
- QFile f(path);
- f.open(QIODevice::ReadOnly);
QByteArray jsonData = f.readAll();
QJsonDocument sceneDocument = QJsonDocument::fromBinaryData(jsonData);
@@ -214,7 +212,7 @@ void GLTFParser::setSource(const QUrl &source)
return;
}
- setBasePath(finfo.dir().absolutePath());
+ setBasePath(QFileInfo(path).dir().absolutePath());
}
/*!