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>
This commit is contained in:
Robin Burchell 2017-01-09 10:44:00 +01:00
parent 1a7ebeb5cb
commit 5723c53708

View File

@ -918,8 +918,6 @@ void Generator::generateMetacall()
fprintf(out, " _id = %s::qt_metacall(_c, _id, _a);\n", superClass.constData()); 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; bool needElse = false;
QVector<FunctionDef> methodList; QVector<FunctionDef> methodList;
@ -927,6 +925,15 @@ void Generator::generateMetacall()
methodList += cdef->slotList; methodList += cdef->slotList;
methodList += cdef->methodList; 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()) { if (methodList.size()) {
needElse = true; needElse = true;
fprintf(out, "if (_c == QMetaObject::InvokeMetaMethod) {\n"); fprintf(out, "if (_c == QMetaObject::InvokeMetaMethod) {\n");