diff options
author | Marco Benelli <marco.benelli@theqtcompany.com> | 2015-11-10 16:23:16 +0100 |
---|---|---|
committer | Marco Benelli <marco.benelli@theqtcompany.com> | 2015-11-27 11:09:19 +0000 |
commit | a3cde0b1ac8f825bedd15e5426af72ae0527ae0c (patch) | |
tree | edcad9bba6c0bd73cead269bf89fd32f5db1e245 | |
parent | a34513c03e626d2738f576c47697d3e009f8f4d6 (diff) |
QmlJs: separate dumping of Qt built-ins and QtQml.
builtins.qmltypes used to contain also definitions that belong to
QtQml. This patch makes qmlplugindump dump only Qt built-ins when
called with the '-builtin' option, and makes dumping of QtQml work
correctly.
Change-Id: I123b9cae6f2557cf281f857df51fae095cbc25cc
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
-rw-r--r-- | tools/qmlplugindump/main.cpp | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp index 36a5c5ab76..0f73afcc7b 100644 --- a/tools/qmlplugindump/main.cpp +++ b/tools/qmlplugindump/main.cpp @@ -75,6 +75,10 @@ #include <qt_windows.h> #endif + +static const uint qtQmlMajorVersion = 2; +static const uint qtQmlMinorVersion = 2; + QString pluginImportPath; bool verbose = false; bool creatable = true; @@ -1056,9 +1060,13 @@ int main(int argc, char *argv[]) getDependencies(engine, pluginImportUri, pluginImportVersion, &dependencies); compactDependencies(&dependencies); - // load the QtQml 2.2 builtins and the dependencies + QString qtQmlImportString = QString::fromLatin1("import QtQml %1.%2") + .arg(qtQmlMajorVersion) + .arg(qtQmlMinorVersion); + + // load the QtQml builtins and the dependencies { - QByteArray code("import QtQml 2.2"); + QByteArray code(qtQmlImportString.toUtf8()); foreach (const QString &moduleToImport, dependencies) { code.append("\nimport "); code.append(moduleToImport.toUtf8()); @@ -1089,14 +1097,40 @@ int main(int argc, char *argv[]) QSet<const QMetaObject *> metas; if (action == Builtins) { + foreach (const QMetaObject *m, defaultReachable) { + if (m->className() == QLatin1String("Qt")) { + metas.insert(m); + break; + } + } + } else if (pluginImportUri == QLatin1String("QtQml")) { + bool ok = false; + const uint major = pluginImportVersion.split('.')[0].toUInt(&ok, 10); + if (!ok) { + std::cerr << "Malformed version string \""<< qPrintable(pluginImportVersion) << "\"." + << std::endl; + return EXIT_INVALIDARGUMENTS; + } + if (major != qtQmlMajorVersion) { + std::cerr << "Unsupported version \"" << qPrintable(pluginImportVersion) + << "\": Major version number must be \"" << qtQmlMajorVersion << "\"." + << std::endl; + return EXIT_INVALIDARGUMENTS; + } metas = defaultReachable; + foreach (const QMetaObject *m, defaultReachable) { + if (m->className() == QLatin1String("Qt")) { + metas.remove(m); + break; + } + } } else { // find a valid QtQuick import QByteArray importCode; QQmlType *qtObjectType = QQmlMetaType::qmlType(&QObject::staticMetaObject); if (!qtObjectType) { std::cerr << "Could not find QtObject type" << std::endl; - importCode = QByteArray("import QtQml 2.2"); + importCode = qtQmlImportString.toUtf8(); } else { QString module = qtObjectType->qmlTypeName(); module = module.mid(0, module.lastIndexOf(QLatin1Char('/'))); |