summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAlexis Menard <alexis.menard@trolltech.com>2011-06-23 09:59:51 (GMT)
committerAlexis Menard <alexis.menard@trolltech.com>2011-06-23 09:59:51 (GMT)
commite1c651f1284f1041ba5e03246686018e363d0e44 (patch)
treecb482b45dc7adcc15ed8f85901d52f0440ae6dbe /tools
parent221fa23ed7307a42e576a6070e37d0152c6a8d08 (diff)
parentfa0332ce6cec38e3ba9396c4c535e65cc8e10770 (diff)
downloadQt-e1c651f1284f1041ba5e03246686018e363d0e44.zip
Qt-e1c651f1284f1041ba5e03246686018e363d0e44.tar.gz
Qt-e1c651f1284f1041ba5e03246686018e363d0e44.tar.bz2
Merge branch '4.8' of git://gitorious.org/qt/qt into 4.8
Diffstat (limited to 'tools')
-rw-r--r--tools/qmlplugindump/main.cpp63
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"