aboutsummaryrefslogtreecommitdiff
path: root/connection.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-03-21 20:22:07 +0900
committerGitHub <noreply@github.com>2018-03-21 20:22:07 +0900
commitef6a94c567f316363bc713294969329dd7f50268 (patch)
treed94ee58a33c0b48593216f7d5da092b878392162 /connection.cpp
parent3fc58ced0f65acae4696946a29ccda832263b4c2 (diff)
parent17d3333a8952e3bd2491080081d00a251157e34a (diff)
downloadlibquotient-ef6a94c567f316363bc713294969329dd7f50268.tar.gz
libquotient-ef6a94c567f316363bc713294969329dd7f50268.zip
Merge pull request #189 from r0kk3rz/master
fix error handling in loadState()
Diffstat (limited to 'connection.cpp')
-rw-r--r--connection.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/connection.cpp b/connection.cpp
index 7ba11145..b3f1ceb8 100644
--- a/connection.cpp
+++ b/connection.cpp
@@ -719,15 +719,18 @@ void Connection::loadState(const QUrl &fromFile)
qCDebug(MAIN) << "No state cache file found";
return;
}
- file.open(QFile::ReadOnly);
+ if(!file.open(QFile::ReadOnly))
+ {
+ qCWarning(MAIN) << "file " << file.fileName() << "failed to open for read";
+ return;
+ }
QByteArray data = file.readAll();
- QJsonParseError e;
auto jsonDoc = d->cacheToBinary ? QJsonDocument::fromBinaryData(data) :
- QJsonDocument::fromJson(data, &e);
- if (e.error != QJsonParseError::NoError)
+ QJsonDocument::fromJson(data);
+ if (jsonDoc.isNull())
{
- qCWarning(MAIN) << "Cache file not found or broken, discarding";
+ qCWarning(MAIN) << "Cache file broken, discarding";
return;
}
auto actualCacheVersionMajor =