Check return value of 'virtual bool QFile::open(QIODeviceBase::OpenMode)'
Signed-off-by: Dylan Schooner <dschooner05@gmail.com>
This commit is contained in:
@@ -9,7 +9,10 @@ class MojangVersionFormatTest : public QObject {
|
||||
static QJsonDocument readJson(const QString path)
|
||||
{
|
||||
QFile jsonFile(path);
|
||||
jsonFile.open(QIODevice::ReadOnly);
|
||||
if (!jsonFile.open(QIODevice::ReadOnly)) {
|
||||
qWarning() << "Failed to open file '" << jsonFile.fileName() << "' for reading!";
|
||||
return QJsonDocument();
|
||||
}
|
||||
auto data = jsonFile.readAll();
|
||||
jsonFile.close();
|
||||
return QJsonDocument::fromJson(data);
|
||||
@@ -17,7 +20,10 @@ class MojangVersionFormatTest : public QObject {
|
||||
static void writeJson(const char* file, QJsonDocument doc)
|
||||
{
|
||||
QFile jsonFile(file);
|
||||
jsonFile.open(QIODevice::WriteOnly | QIODevice::Text);
|
||||
if (!jsonFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
qCritical() << "Failed to open file '" << jsonFile.fileName() << "' for writing!";
|
||||
return;
|
||||
}
|
||||
auto data = doc.toJson(QJsonDocument::Indented);
|
||||
qDebug() << QString::fromUtf8(data);
|
||||
jsonFile.write(data);
|
||||
|
||||
Reference in New Issue
Block a user