diff options
author | Ahmad Samir <a.samirh78@gmail.com> | 2023-05-15 14:41:14 +0300 |
---|---|---|
committer | Ahmad Samir <a.samirh78@gmail.com> | 2023-05-18 22:39:25 +0300 |
commit | 976c3615a336ddb75d4430ff78fa2d1c20b45db2 (patch) | |
tree | e163d06cd9373c80152422427a4ca864a8c9faef /src/tools/moc/moc.cpp | |
parent | 5c7702a8f9c8cf3722945b643dc3d21303c2482c (diff) |
Moc: fix some narrowing conversion warnings by using range operations
I.e. range-for and in one case QList::append(iterator, iterator).
Drive-by changes:
- Check a QByteArray isn't empty before using at()
- Shorten a long line, QString::fromLocal8Bit() works with QByteArray
Pick-to: 6.5
Change-Id: I7e54ce39f65ccb1fe5e60693ac98e239b9f0d794
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/tools/moc/moc.cpp')
-rw-r--r-- | src/tools/moc/moc.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index c71f2cec53..be7425785e 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -1084,9 +1084,8 @@ void Moc::generate(FILE *out, FILE *jsonOutput) if (!noInclude) { if (includePath.size() && !includePath.endsWith('/')) includePath += '/'; - for (int i = 0; i < includeFiles.size(); ++i) { - QByteArray inc = includeFiles.at(i); - if (inc.at(0) != '<' && inc.at(0) != '"') { + for (QByteArray inc : std::as_const(includeFiles)) { + if (!inc.isEmpty() && inc.at(0) != '<' && inc.at(0) != '"') { if (includePath.size() && includePath != "./") inc.prepend(includePath); inc = '\"' + inc + '\"'; @@ -1450,9 +1449,11 @@ void Moc::parsePluginData(ClassDef *def) } else if (l == "FILE") { next(STRING_LITERAL); QByteArray metaDataFile = unquotedLexem(); - QFileInfo fi(QFileInfo(QString::fromLocal8Bit(currentFilenames.top().constData())).dir(), QString::fromLocal8Bit(metaDataFile.constData())); - for (int j = 0; j < includes.size() && !fi.exists(); ++j) { - const IncludePath &p = includes.at(j); + QFileInfo fi(QFileInfo(QString::fromLocal8Bit(currentFilenames.top())).dir(), + QString::fromLocal8Bit(metaDataFile)); + for (const IncludePath &p : std::as_const(includes)) { + if (fi.exists()) + break; if (p.isFrameworkPath) continue; @@ -1879,8 +1880,7 @@ void Moc::checkProperties(ClassDef *cdef) continue; } - for (int j = 0; j < cdef->publicList.size(); ++j) { - const FunctionDef &f = cdef->publicList.at(j); + for (const FunctionDef &f : std::as_const(cdef->publicList)) { if (f.name != p.read) continue; if (!f.isConst) // get functions must be const |