diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index 128da4fd01..f295235c1c 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -539,9 +539,9 @@ void Generator::generateCode() // metatypes for all exposed methods // because we definitely printed something above, this section doesn't need comma control - for (const QList &methodContainer : - { cdef->signalList, cdef->slotList, cdef->methodList }) { - for (const FunctionDef &fdef : methodContainer) { + const auto allMethods = {&cdef->signalList, &cdef->slotList, &cdef->methodList}; + for (const QList *methodContainer : allMethods) { + for (const FunctionDef &fdef : *methodContainer) { fprintf(out, ",\n // method '%s'\n %s", fdef.name.constData(), stringForType(fdef.type.name, false).constData()); for (const auto &argument: fdef.arguments)