summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRobin Burchell <robin.burchell@crimson.no>2017-01-09 10:44:00 +0100
committerRobin Burchell <robin.burchell@crimson.no>2017-01-11 12:31:00 +0000
commit5723c53708559d6e016ddcba53d9f5302493675c (patch)
tree873b8b84c814132b3582644fa83709a74d8a7eff /src
parent1a7ebeb5cb03a13a80229890cde7b002c0bb05da (diff)
moc: Don't test _id if there are no methods or properties
This is unnecessary (as the fallback behavior is return _id anyway), and it makes coverity unhappy. Coverity-Id: 173293 Change-Id: I91c016f3ed363319c6413ab3c2688698faf4f10f Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src')
-rw-r--r--src/tools/moc/generator.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp
index 016ac97228..674398e783 100644
--- a/src/tools/moc/generator.cpp
+++ b/src/tools/moc/generator.cpp
@@ -918,8 +918,6 @@ void Generator::generateMetacall()
fprintf(out, " _id = %s::qt_metacall(_c, _id, _a);\n", superClass.constData());
}
- fprintf(out, " if (_id < 0)\n return _id;\n");
- fprintf(out, " ");
bool needElse = false;
QVector<FunctionDef> methodList;
@@ -927,6 +925,15 @@ void Generator::generateMetacall()
methodList += cdef->slotList;
methodList += cdef->methodList;
+ // If there are no methods or properties, we will return _id anyway, so
+ // don't emit this comparison -- it is unnecessary, and it makes coverity
+ // unhappy.
+ if (methodList.size() || cdef->propertyList.size()) {
+ fprintf(out, " if (_id < 0)\n return _id;\n");
+ }
+
+ fprintf(out, " ");
+
if (methodList.size()) {
needElse = true;
fprintf(out, "if (_c == QMetaObject::InvokeMetaMethod) {\n");