aboutsummaryrefslogtreecommitdiffstats
path: root/tools/qmlplugindump
diff options
context:
space:
mode:
authorAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-08-11 13:37:27 +0300
committerAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-08-22 08:32:23 +0000
commit909d6498edbf31fcc21a137b7244c580afdbf749 (patch)
tree57ba351e4fb03f14e82a8308b2c2ba0901474728 /tools/qmlplugindump
parent3ef4fac9ff3f785d3ccbda4b28ec2c0ea2ee1b59 (diff)
tools: replace 'foreach' with 'range for'
Catch rvalues to prevent detach()'ing. Change-Id: I7be159a405c994429c0eee10805bfe96fcf4c806 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tools/qmlplugindump')
-rw-r--r--tools/qmlplugindump/main.cpp24
1 files changed, 15 insertions, 9 deletions
diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp
index ceffebf14b..a5f825907a 100644
--- a/tools/qmlplugindump/main.cpp
+++ b/tools/qmlplugindump/main.cpp
@@ -205,7 +205,8 @@ QByteArray convertToId(const QMetaObject *mo)
// Collect all metaobjects for types registered with qmlRegisterType() without parameters
void collectReachableMetaObjectsWithoutQmlName(QQmlEnginePrivate *engine, QSet<const QMetaObject *>& metas ) {
- foreach (const QQmlType *ty, QQmlMetaType::qmlAllTypes()) {
+ const auto qmlAllTypes = QQmlMetaType::qmlAllTypes();
+ for (const QQmlType *ty : qmlAllTypes) {
if ( ! metas.contains(ty->metaObject()) ) {
if (!ty->isComposite()) {
collectReachableMetaObjects(engine, ty, &metas);
@@ -225,7 +226,8 @@ QSet<const QMetaObject *> collectReachableMetaObjects(QQmlEngine *engine,
metas.insert(FriendlyQObject::qtMeta());
QHash<QByteArray, QSet<QByteArray> > extensions;
- foreach (const QQmlType *ty, QQmlMetaType::qmlTypes()) {
+ const auto qmlTypes = QQmlMetaType::qmlTypes();
+ for (const QQmlType *ty : qmlTypes) {
if (!ty->isCreatable())
noncreatables.insert(ty->metaObject());
if (ty->isSingleton())
@@ -275,7 +277,7 @@ QSet<const QMetaObject *> collectReachableMetaObjects(QQmlEngine *engine,
if (creatable) {
// find even more QMetaObjects by instantiating QML types and running
// over the instances
- foreach (QQmlType *ty, QQmlMetaType::qmlTypes()) {
+ for (QQmlType *ty : qmlTypes) {
if (skip.contains(ty))
continue;
if (ty->isExtendedType())
@@ -766,7 +768,8 @@ static bool readDependenciesData(QString dependenciesFile, const QByteArray &fil
const QStringList requiredKeys = QStringList() << QStringLiteral("name")
<< QStringLiteral("type")
<< QStringLiteral("version");
- foreach (const QJsonValue &dep, doc.array()) {
+ const auto deps = doc.array();
+ for (const QJsonValue &dep : deps) {
if (dep.isObject()) {
QJsonObject obj = dep.toObject();
for (const QString &requiredKey : requiredKeys)
@@ -833,7 +836,8 @@ static bool getDependencies(const QQmlEngine &engine, const QString &pluginImpor
QStringList commandArgs = QStringList()
<< QLatin1String("-qmlFiles")
<< QLatin1String("-");
- foreach (const QString &path, engine.importPathList())
+ const auto importPathList = engine.importPathList();
+ for (const QString &path : importPathList)
commandArgs << QLatin1String("-importPath") << path;
QProcess importScanner;
@@ -1132,8 +1136,9 @@ int main(int argc, char *argv[])
QQmlComponent c(&engine);
c.setData(code, QUrl::fromLocalFile(pluginImportPath + "/loaddependencies.qml"));
c.create();
- if (!c.errors().isEmpty()) {
- foreach (const QQmlError &error, c.errors())
+ const auto errors = c.errors();
+ if (!errors.isEmpty()) {
+ for (const QQmlError &error : errors)
std::cerr << qPrintable( error.toString() ) << std::endl;
return EXIT_IMPORTERROR;
}
@@ -1218,8 +1223,9 @@ int main(int argc, char *argv[])
c.setData(code, QUrl::fromLocalFile(pluginImportPath + "/typelist.qml"));
c.create();
- if (!c.errors().isEmpty()) {
- foreach (const QQmlError &error, c.errors())
+ const auto errors = c.errors();
+ if (!errors.isEmpty()) {
+ for (const QQmlError &error : errors)
std::cerr << qPrintable( error.toString() ) << std::endl;
return EXIT_IMPORTERROR;
}