1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-29 17:15:34 +00:00

Check if file is successfully opened

This commit is contained in:
Andrei Kortunov 2024-07-01 20:51:44 +04:00
parent dc7407a34c
commit 871263d436
2 changed files with 18 additions and 3 deletions

View file

@ -36,7 +36,12 @@ namespace Misc
return QIcon();
QFile iconFile(fileName);
iconFile.open(QIODevice::ReadOnly);
if (!iconFile.open(QIODevice::ReadOnly))
{
qDebug() << "Failed to open icon file:" << fileName;
return QIcon();
}
auto content = iconFile.readAll();
if (!content.startsWith("<?xml"))
return QIcon(fileName);

View file

@ -43,7 +43,12 @@ namespace Platform
setStyle("windows");
QFile file(getStyleSheetPath());
file.open(QIODevice::ReadOnly);
if (!file.open(QIODevice::ReadOnly))
{
qDebug() << "Failed to open style sheet file:" << getStyleSheetPath();
return;
}
setStyleSheet(file.readAll());
}
}
@ -60,7 +65,12 @@ namespace Platform
setStyle("windows");
QFile file(getStyleSheetPath());
file.open(QIODevice::ReadOnly);
if (!file.open(QIODevice::ReadOnly))
{
qDebug() << "Failed to open style sheet file:" << getStyleSheetPath();
return;
}
setStyleSheet(file.readAll());
}
else