summaryrefslogtreecommitdiffstats
path: root/src/tools/moc/main.cpp
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2024-03-22 17:39:49 +0100
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2024-04-14 00:04:26 +0200
commit4183fa4c0b75a76fbc687298f4513971a9230152 (patch)
tree4b73f3e9105467fff35ffcbd1e93c538b003046f /src/tools/moc/main.cpp
parent2a7c71bef061d3d54e4de3cd4117e0998567028f (diff)
Tools: handle file opening failure
Most of the cases, a file handle (stdin/out) is opened without checking for error. That operation may still fail, so check for it. Change-Id: I30c3e7b40858acd8b1662622129bd6557722dccd Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/tools/moc/main.cpp')
-rw-r--r--src/tools/moc/main.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/tools/moc/main.cpp b/src/tools/moc/main.cpp
index 3df832cc2e..bb51352519 100644
--- a/src/tools/moc/main.cpp
+++ b/src/tools/moc/main.cpp
@@ -449,11 +449,14 @@ int runMoc(int argc, char **argv)
if (filename.isEmpty()) {
filename = QStringLiteral("standard input");
- in.open(stdin, QIODevice::ReadOnly);
+ if (!in.open(stdin, QIODevice::ReadOnly)) {
+ fprintf(stderr, "moc: cannot open standard input: %s\n", qPrintable(in.errorString()));
+ return 1;
+ }
} else {
in.setFileName(filename);
if (!in.open(QIODevice::ReadOnly)) {
- fprintf(stderr, "moc: %s: No such file\n", qPrintable(filename));
+ fprintf(stderr, "moc: cannot open %s: %s\n", qPrintable(filename), qPrintable(in.errorString()));
return 1;
}
moc.filename = filename.toLocal8Bit();