diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2011-06-22 14:34:13 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2011-06-22 14:34:13 (GMT) |
commit | f58ca7944eb9a978f4ebc3b64428f0b27ecba2b0 (patch) | |
tree | e8356828b2dbbd771148c1d78ba7d23cd984f185 /tools | |
parent | 078a68ffc84a745830535f1eb0e19ab8a190f542 (diff) | |
parent | b1c746eefffc84403e9a7c0ea9080408d6428bc3 (diff) | |
download | Qt-f58ca7944eb9a978f4ebc3b64428f0b27ecba2b0.zip Qt-f58ca7944eb9a978f4ebc3b64428f0b27ecba2b0.tar.gz Qt-f58ca7944eb9a978f4ebc3b64428f0b27ecba2b0.tar.bz2 |
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-qml-staging into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/qt-qml-staging:
Fix QDeclarativeInspector when starting with ,block
qmlplugindump: Add -v option.
qmlplugindump: Fix emitted tooling version.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qmlplugindump/main.cpp | 63 |
1 files changed, 40 insertions, 23 deletions
diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp index f398358..403e3b6 100644 --- a/tools/qmlplugindump/main.cpp +++ b/tools/qmlplugindump/main.cpp @@ -66,6 +66,7 @@ #endif QString pluginImportPath; +bool verbose = false; void collectReachableMetaObjects(const QMetaObject *meta, QSet<const QMetaObject *> *metas) { @@ -88,13 +89,15 @@ void collectReachableMetaObjects(QObject *object, QSet<const QMetaObject *> *met return; const QMetaObject *meta = object->metaObject(); - qDebug() << "Processing object" << meta->className(); + if (verbose) + qDebug() << "Processing object" << meta->className(); collectReachableMetaObjects(meta, metas); for (int index = 0; index < meta->propertyCount(); ++index) { QMetaProperty prop = meta->property(index); if (QDeclarativeMetaType::isQObject(prop.userType())) { - qDebug() << " Processing property" << prop.name(); + if (verbose) + qDebug() << " Processing property" << prop.name(); currentProperty = QString("%1::%2").arg(meta->className(), prop.name()); // if the property was not initialized during construction, @@ -187,9 +190,15 @@ QSet<const QMetaObject *> collectReachableMetaObjects(const QString &importCode, foreach (const QDeclarativeType *ty, QDeclarativeMetaType::qmlTypes()) { 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; QByteArray code = importCode.toUtf8(); code += tyName; @@ -202,7 +211,7 @@ QSet<const QMetaObject *> collectReachableMetaObjects(const QString &importCode, if (object) collectReachableMetaObjects(object, &metas); else - qDebug() << "Could not create" << tyName << ":" << c.errorString(); + qWarning() << "Could not create" << tyName << ":" << c.errorString(); } return metas; @@ -424,9 +433,9 @@ void sigSegvHandler(int) { void printUsage(const QString &appName) { qWarning() << qPrintable(QString( - "Usage: %1 [-notrelocatable] module.uri version [module/import/path]\n" - " %1 -path path/to/qmldir/directory [version]\n" - " %1 -builtins\n" + "Usage: %1 [-v] [-notrelocatable] module.uri version [module/import/path]\n" + " %1 [-v] -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)); } @@ -436,13 +445,13 @@ int main(int argc, char *argv[]) #ifdef Q_OS_UNIX // qmldump may crash, but we don't want any crash handlers to pop up // therefore we intercept the segfault and just exit() ourselves - struct sigaction action; + struct sigaction sigAction; - sigemptyset(&action.sa_mask); - action.sa_handler = &sigSegvHandler; - action.sa_flags = 0; + sigemptyset(&sigAction.sa_mask); + sigAction.sa_handler = &sigSegvHandler; + sigAction.sa_flags = 0; - sigaction(SIGSEGV, &action, 0); + sigaction(SIGSEGV, &sigAction, 0); #endif #ifdef QT_SIMULATOR @@ -452,10 +461,7 @@ int main(int argc, char *argv[]) QApplication app(argc, argv); const QStringList args = app.arguments(); const QString appName = QFileInfo(app.applicationFilePath()).baseName(); - if (!(args.size() >= 3 - || (args.size() == 2 - && (args.at(1) == QLatin1String("--builtins") - || args.at(1) == QLatin1String("-builtins"))))) { + if (args.size() < 2) { printUsage(appName); return EXIT_INVALIDARGUMENTS; } @@ -463,8 +469,9 @@ int main(int argc, char *argv[]) QString pluginImportUri; QString pluginImportVersion; bool relocatable = true; - bool pathImport = false; - if (args.size() >= 3) { + enum Action { Uri, Path, Builtins }; + Action action = Uri; + { QStringList positionalArgs; foreach (const QString &arg, args) { if (!arg.startsWith(QLatin1Char('-'))) { @@ -477,14 +484,19 @@ int main(int argc, char *argv[]) relocatable = false; } else if (arg == QLatin1String("--path") || arg == QLatin1String("-path")) { - pathImport = true; + action = Path; + } else if (arg == QLatin1String("--builtins") + || arg == QLatin1String("-builtins")) { + action = Builtins; + } else if (arg == QLatin1String("-v")) { + verbose = true; } else { qWarning() << "Invalid argument: " << arg; return EXIT_INVALIDARGUMENTS; } } - if (!pathImport) { + if (action == Uri) { if (positionalArgs.size() != 3 && positionalArgs.size() != 4) { qWarning() << "Incorrect number of positional arguments"; return EXIT_INVALIDARGUMENTS; @@ -493,7 +505,7 @@ int main(int argc, char *argv[]) pluginImportVersion = positionalArgs[2]; if (positionalArgs.size() >= 4) pluginImportPath = positionalArgs[3]; - } else { + } else if (action == Path) { if (positionalArgs.size() != 2 && positionalArgs.size() != 3) { qWarning() << "Incorrect number of positional arguments"; return EXIT_INVALIDARGUMENTS; @@ -501,6 +513,11 @@ int main(int argc, char *argv[]) pluginImportPath = QDir::fromNativeSeparators(positionalArgs[1]); if (positionalArgs.size() == 3) pluginImportVersion = positionalArgs[2]; + } else if (action == Builtins) { + if (positionalArgs.size() != 1) { + qWarning() << "Incorrect number of positional arguments"; + return EXIT_INVALIDARGUMENTS; + } } } @@ -516,11 +533,11 @@ int main(int argc, char *argv[]) // this will hold the meta objects we want to dump information of QSet<const QMetaObject *> metas; - if (pluginImportUri.isEmpty() && !pathImport) { + if (action == Builtins) { metas = defaultReachable; } else { // find all QMetaObjects reachable when the specified module is imported - if (!pathImport) { + if (action != Path) { importCode += QString("import %0 %1\n").arg(pluginImportUri, pluginImportVersion).toAscii(); } else { // pluginImportVersion can be empty @@ -567,7 +584,7 @@ int main(int argc, char *argv[]) QmlStreamWriter qml(&bytes); qml.writeStartDocument(); - qml.writeLibraryImport(QLatin1String("QtQuick.tooling"), 1, 0); + qml.writeLibraryImport(QLatin1String("QtQuick.tooling"), 1, 1); qml.write("\n" "// This file describes the plugin-supplied types contained in the library.\n" "// It is used for QML tooling purposes only.\n" |