Check return value of 'virtual bool QFile::open(QIODeviceBase::OpenMode)'

Signed-off-by: Dylan Schooner <dschooner05@gmail.com>
This commit is contained in:
Dylan Schooner
2025-10-30 03:15:14 -04:00
parent 2982e6e7c9
commit 8d42bdaf6b
9 changed files with 63 additions and 28 deletions

View File

@@ -48,7 +48,10 @@ class LibraryTest : public QObject {
LibraryPtr readMojangJson(const QString path)
{
QFile jsonFile(path);
jsonFile.open(QIODevice::ReadOnly);
if (!jsonFile.open(QIODevice::ReadOnly)) {
qCritical() << "Failed to open file '" << jsonFile.fileName() << "' for reading!";
return LibraryPtr();
}
auto data = jsonFile.readAll();
jsonFile.close();
ProblemContainer problems;