aboutsummaryrefslogtreecommitdiffstats
path: root/tools/qmlplugindump
diff options
context:
space:
mode:
Diffstat (limited to 'tools/qmlplugindump')
-rw-r--r--tools/qmlplugindump/main.cpp53
1 files changed, 31 insertions, 22 deletions
diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp
index e4482ba2a6..dd7ae36c5d 100644
--- a/tools/qmlplugindump/main.cpp
+++ b/tools/qmlplugindump/main.cpp
@@ -212,7 +212,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);
@@ -232,7 +233,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())
@@ -282,7 +284,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())
@@ -773,7 +775,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)
@@ -840,7 +843,9 @@ static bool getDependencies(const QQmlEngine &engine, const QString &pluginImpor
QStringList commandArgs = QStringList()
<< QLatin1String("-qmlFiles")
<< QLatin1String("-");
- foreach (const QString &path, engine.importPathList())
+ QStringList importPathList = engine.importPathList();
+ importPathList.removeOne(QStringLiteral("qrc:/qt-project.org/imports"));
+ for (const QString &path : importPathList)
commandArgs << QLatin1String("-importPath") << path;
QProcess importScanner;
@@ -866,6 +871,8 @@ static bool getDependencies(const QQmlEngine &engine, const QString &pluginImpor
if (!readDependenciesData(QLatin1String("<outputOfQmlimportscanner>"), depencenciesData,
dependencies, QStringList(pluginImportUri), forceQtQuickDependency)) {
std::cerr << "failed to process output of qmlimportscanner" << std::endl;
+ if (importScanner.exitCode() != 0)
+ std::cerr << importScanner.readAllStandardError().toStdString();
return false;
}
@@ -884,20 +891,20 @@ bool compactDependencies(QStringList *dependencies)
if (dependencies->isEmpty())
return false;
dependencies->sort();
- QStringList oldDep = dependencies->first().split(QLatin1Char(' '));
+ QStringList oldDep = dependencies->constFirst().split(QLatin1Char(' '));
Q_ASSERT(oldDep.size() == 2);
int oldPos = 0;
for (int idep = 1; idep < dependencies->size(); ++idep) {
QString depStr = dependencies->at(idep);
const QStringList newDep = depStr.split(QLatin1Char(' '));
Q_ASSERT(newDep.size() == 2);
- if (newDep.first() != oldDep.first()) {
+ if (newDep.constFirst() != oldDep.constFirst()) {
if (++oldPos != idep)
dependencies->replace(oldPos, depStr);
oldDep = newDep;
} else {
- QStringList v1 = oldDep.last().split(QLatin1Char('.'));
- QStringList v2 = newDep.last().split(QLatin1Char('.'));
+ const QStringList v1 = oldDep.constLast().split(QLatin1Char('.'));
+ const QStringList v2 = newDep.constLast().split(QLatin1Char('.'));
Q_ASSERT(v1.size() == 2);
Q_ASSERT(v2.size() == 2);
bool ok;
@@ -906,9 +913,9 @@ bool compactDependencies(QStringList *dependencies)
int major2 = v2.first().toInt(&ok);
Q_ASSERT(ok);
if (major1 != major2) {
- std::cerr << "Found a dependency on " << qPrintable(oldDep.first())
- << " with two major versions:" << qPrintable(oldDep.last())
- << " and " << qPrintable(newDep.last())
+ std::cerr << "Found a dependency on " << qPrintable(oldDep.constFirst())
+ << " with two major versions:" << qPrintable(oldDep.constLast())
+ << " and " << qPrintable(newDep.constLast())
<< " which is unsupported, discarding smaller version" << std::endl;
if (major1 < major2)
dependencies->replace(oldPos, depStr);
@@ -1091,18 +1098,18 @@ int main(int argc, char *argv[])
std::cerr << "Incorrect number of positional arguments" << std::endl;
return EXIT_INVALIDARGUMENTS;
}
- pluginImportUri = positionalArgs[1];
+ pluginImportUri = positionalArgs.at(1);
pluginImportVersion = positionalArgs[2];
if (positionalArgs.size() >= 4)
- pluginImportPath = positionalArgs[3];
+ pluginImportPath = positionalArgs.at(3);
} else if (action == Path) {
if (positionalArgs.size() != 2 && positionalArgs.size() != 3) {
std::cerr << "Incorrect number of positional arguments" << std::endl;
return EXIT_INVALIDARGUMENTS;
}
- pluginImportPath = QDir::fromNativeSeparators(positionalArgs[1]);
+ pluginImportPath = QDir::fromNativeSeparators(positionalArgs.at(1));
if (positionalArgs.size() == 3)
- pluginImportVersion = positionalArgs[2];
+ pluginImportVersion = positionalArgs.at(2);
} else if (action == Builtins) {
if (positionalArgs.size() != 1) {
std::cerr << "Incorrect number of positional arguments" << std::endl;
@@ -1124,7 +1131,7 @@ int main(int argc, char *argv[])
QStringList mergeDependencies;
QString mergeComponents;
if (!mergeFile.isEmpty()) {
- QStringList merge = readQmlTypes(mergeFile);
+ const QStringList merge = readQmlTypes(mergeFile);
if (!merge.isEmpty()) {
QRegularExpression re("(\\w+\\.*\\w*\\s*\\d+\\.\\d+)");
QRegularExpressionMatchIterator i = re.globalMatch(merge[1]);
@@ -1166,8 +1173,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;
}
@@ -1196,7 +1204,7 @@ int main(int argc, char *argv[])
}
} else if (pluginImportUri == QLatin1String("QtQml")) {
bool ok = false;
- const uint major = pluginImportVersion.split('.')[0].toUInt(&ok, 10);
+ const uint major = pluginImportVersion.splitRef('.').at(0).toUInt(&ok, 10);
if (!ok) {
std::cerr << "Malformed version string \""<< qPrintable(pluginImportVersion) << "\"."
<< std::endl;
@@ -1252,8 +1260,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;
}