diff options
author | Alan Alpert <aalpert@blackberry.com> | 2013-05-02 10:42:31 -0700 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-06-13 14:53:55 +0200 |
commit | 6586505e6bf157089137f3bbf5f31cb70cfaa614 (patch) | |
tree | e0e3236d8db0659b5be34dfb3d589c88645e1547 /tools | |
parent | a5854e077214cc40f63006a1ad66b89a4fc86304 (diff) |
Add --noinstantiate to qmlplugindump
This flag allows you to run qmlplugindump on plugins which cannot safely
create objects, such as plugins with unusual requirements or missing
essential dependencies.
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
(cherry picked from commit 0462193b6fb97fbe7ccde496c33d82d4d5fce8c0)
Change-Id: I0d1ff7f94e00a8aab94c0aff012d78db5193400f
Reviewed-by: Alan Alpert <aalpert@blackberry.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qmlplugindump/main.cpp | 82 |
1 files changed, 44 insertions, 38 deletions
diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp index 9d5cd1db15..4337db1689 100644 --- a/tools/qmlplugindump/main.cpp +++ b/tools/qmlplugindump/main.cpp @@ -71,6 +71,7 @@ QString pluginImportPath; bool verbose = false; +bool creatable = true; QString currentProperty; QString inObjectInstantiation; @@ -225,46 +226,48 @@ QSet<const QMetaObject *> collectReachableMetaObjects(QQmlEngine *engine, const qmlTypesByCppName[baseCpp] = baseExports; } - // find even more QMetaObjects by instantiating QML types and running - // over the instances - foreach (QQmlType *ty, QQmlMetaType::qmlTypes()) { - if (skip.contains(ty)) - continue; - if (ty->isExtendedType()) - continue; - if (!ty->isCreatable()) - continue; - if (ty->typeName() == "QQmlComponent") - continue; - - QString tyName = ty->qmlTypeName(); - tyName = tyName.mid(tyName.lastIndexOf(QLatin1Char('/')) + 1); - if (tyName.isEmpty()) - continue; - - inObjectInstantiation = tyName; - QObject *object = 0; - - if (ty->isSingleton()) { - QQmlType::SingletonInstanceInfo *siinfo = ty->singletonInstanceInfo(); - if (siinfo->qobjectCallback) { - siinfo->init(engine); - collectReachableMetaObjects(object, &metas); - object = siinfo->qobjectApi(engine); + if (creatable) { + // find even more QMetaObjects by instantiating QML types and running + // over the instances + foreach (QQmlType *ty, QQmlMetaType::qmlTypes()) { + if (skip.contains(ty)) + continue; + if (ty->isExtendedType()) + continue; + if (!ty->isCreatable()) + continue; + if (ty->typeName() == "QQmlComponent") + continue; + + QString tyName = ty->qmlTypeName(); + tyName = tyName.mid(tyName.lastIndexOf(QLatin1Char('/')) + 1); + if (tyName.isEmpty()) + continue; + + inObjectInstantiation = tyName; + QObject *object = 0; + + if (ty->isSingleton()) { + QQmlType::SingletonInstanceInfo *siinfo = ty->singletonInstanceInfo(); + if (siinfo->qobjectCallback) { + siinfo->init(engine); + collectReachableMetaObjects(object, &metas); + object = siinfo->qobjectApi(engine); + } else { + inObjectInstantiation.clear(); + continue; // we don't handle QJSValue singleton types. + } } else { - inObjectInstantiation.clear(); - continue; // we don't handle QJSValue singleton types. + object = ty->create(); } - } else { - object = ty->create(); - } - inObjectInstantiation.clear(); + inObjectInstantiation.clear(); - if (object) - collectReachableMetaObjects(object, &metas); - else - qWarning() << "Could not create" << tyName; + if (object) + collectReachableMetaObjects(object, &metas); + else + qWarning() << "Could not create" << tyName; + } } return metas; @@ -540,8 +543,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.folderlistmodel 2.0 /home/user/dev/qt-install/imports").arg( appName)); @@ -598,6 +601,9 @@ int main(int argc, char *argv[]) } else if (arg == QLatin1String("--relocatable") || arg == QLatin1String("-relocatable")) { relocatable = true; + } else if (arg == QLatin1String("--noinstantiate") + || arg == QLatin1String("-noinstantiate")) { + creatable = false; } else if (arg == QLatin1String("--path") || arg == QLatin1String("-path")) { action = Path; |