From f0be67b54d2b82ef57c9e3ff02b89e92b0ce2e96 Mon Sep 17 00:00:00 2001 From: Daniel Pesch Date: Wed, 22 Jan 2014 22:18:59 +0100 Subject: qmlplugindump is missing --noinstantiate option on Qt 4.8 Backport of --noinstantiate option from Qt 5.0. Task-number: QTBUG-36380 Change-Id: I80694aa94c5d5cceaf2751d1e3efc80e4f316709 Signed-off-by: Daniel Pesch Reviewed-by: Alan Alpert --- tools/qmlplugindump/main.cpp | 60 ++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 27 deletions(-) (limited to 'tools') diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp index cf422cdfb5..ecb10e7d3e 100644 --- a/tools/qmlplugindump/main.cpp +++ b/tools/qmlplugindump/main.cpp @@ -67,6 +67,7 @@ QString pluginImportPath; bool verbose = false; +bool creatable = true; QString currentProperty; QString inObjectInstantiation; @@ -218,31 +219,33 @@ QSet collectReachableMetaObjects(const QListisExtendedType()) - continue; - if (!ty->isCreatable()) - continue; - if (ty->typeName() == "QDeclarativeComponent") - continue; - - QByteArray tyName = ty->qmlTypeName(); - tyName = tyName.mid(tyName.lastIndexOf('/') + 1); - if (tyName.isEmpty()) - continue; - - inObjectInstantiation = tyName; - QObject *object = ty->create(); - inObjectInstantiation.clear(); - - if (object) - collectReachableMetaObjects(object, &metas); - else - qWarning() << "Could not create" << tyName; + if (creatable) { + // find even more QMetaObjects by instantiating QML types and running + // over the instances + foreach (QDeclarativeType *ty, QDeclarativeMetaType::qmlTypes()) { + if (skip.contains(ty)) + continue; + if (ty->isExtendedType()) + continue; + if (!ty->isCreatable()) + continue; + if (ty->typeName() == "QDeclarativeComponent") + continue; + + QByteArray tyName = ty->qmlTypeName(); + tyName = tyName.mid(tyName.lastIndexOf('/') + 1); + if (tyName.isEmpty()) + continue; + + inObjectInstantiation = tyName; + QObject *object = ty->create(); + inObjectInstantiation.clear(); + + if (object) + collectReachableMetaObjects(object, &metas); + else + qWarning() << "Could not create" << tyName; + } } return metas; @@ -482,8 +485,8 @@ void sigSegvHandler(int) { void printUsage(const QString &appName) { qWarning() << qPrintable(QString( - "Usage: %1 [-v] [-[non]relocatable] module.uri version [module/import/path]\n" - " %1 [-v] -path path/to/qmldir/directory [version]\n" + "Usage: %1 [-v] [-noinstantiate] [-[non]relocatable] module.uri version [module/import/path]\n" + " %1 [-v] [-noinstantiate] -path path/to/qmldir/directory [version]\n" " %1 [-v] -builtins\n" "Example: %1 Qt.labs.particles 4.7 /home/user/dev/qt-install/imports").arg( appName)); @@ -544,6 +547,9 @@ int main(int argc, char *argv[]) action = Builtins; } else if (arg == QLatin1String("-v")) { verbose = true; + } else if (arg == QLatin1String("--noinstantiate") + || arg == QLatin1String("-noinstantiate")) { + creatable = false; } else { qWarning() << "Invalid argument: " << arg; return EXIT_INVALIDARGUMENTS; -- cgit v1.2.1