diff options
author | Christian Kamm <christian.d.kamm@nokia.com> | 2011-06-22 15:13:56 (GMT) |
---|---|---|
committer | Christian Kamm <christian.d.kamm@nokia.com> | 2011-06-23 08:42:23 (GMT) |
commit | 21af9f0be1dd0d9be6c3767074fdfbd54e3b8372 (patch) | |
tree | b73dbbc6ab27cf47a5a785626751d16c65e66734 /tools | |
parent | 19b666195e293a71ef918f4a7f91d7f8be5f69bc (diff) | |
download | Qt-21af9f0be1dd0d9be6c3767074fdfbd54e3b8372.zip Qt-21af9f0be1dd0d9be6c3767074fdfbd54e3b8372.tar.gz Qt-21af9f0be1dd0d9be6c3767074fdfbd54e3b8372.tar.bz2 |
qmlplugindump: For extended types, remove exports of the base object.
Reviewed-by: Kai Koehne
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qmlplugindump/main.cpp | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp index 403e3b6..b414c3f 100644 --- a/tools/qmlplugindump/main.cpp +++ b/tools/qmlplugindump/main.cpp @@ -160,29 +160,36 @@ QSet<const QMetaObject *> collectReachableMetaObjects(const QString &importCode, collectReachableMetaObjects(ty, &metas); } - // Adjust ids of extended objects. - // The chain ends up being: - // __extended__.originalname - the base object - // __extension_0_.originalname - first extension - // .. - // __extension_n-2_.originalname - second to last extension - // originalname - last extension - // ### does this actually work for multiple extensions? it seems like the prototypes might be wrong - foreach (const QByteArray &extendedCpp, extensions.keys()) { - cppToId.remove(extendedCpp); - const QByteArray extendedId = convertToId(extendedCpp); - cppToId.insert(extendedCpp, "__extended__." + extendedId); - QSet<QByteArray> extensionCppNames = extensions.value(extendedCpp); - int c = 0; + // Adjust exports of the base object if there are extensions. + // For each export of a base object there can be a single extension object overriding it. + // Example: QDeclarativeGraphicsWidget overrides the QtQuick/QGraphicsWidget export + // of QGraphicsWidget. + foreach (const QByteArray &baseCpp, extensions.keys()) { + QSet<const QDeclarativeType *> baseExports = qmlTypesByCppName.value(baseCpp); + + const QSet<QByteArray> extensionCppNames = extensions.value(baseCpp); foreach (const QByteArray &extensionCppName, extensionCppNames) { - if (c != extensionCppNames.size() - 1) { - QByteArray adjustedName = QString("__extension__%1.%2").arg(QString::number(c), QString(extendedId)).toAscii(); - cppToId.insert(extensionCppName, adjustedName); - } else { - cppToId.insert(extensionCppName, extendedId); + const QSet<const QDeclarativeType *> extensionExports = qmlTypesByCppName.value(extensionCppName); + + // remove extension exports from base imports + // unfortunately the QDeclarativeType pointers don't match, so can't use QSet::substract + QSet<const QDeclarativeType *> newBaseExports; + foreach (const QDeclarativeType *baseExport, baseExports) { + bool match = false; + foreach (const QDeclarativeType *extensionExport, extensionExports) { + if (baseExport->module() == extensionExport->module() + && baseExport->majorVersion() == extensionExport->majorVersion() + && baseExport->minorVersion() == extensionExport->minorVersion()) { + match = true; + break; + } + } + if (!match) + newBaseExports.insert(baseExport); } - ++c; + baseExports = newBaseExports; } + qmlTypesByCppName[baseCpp] = baseExports; } // find even more QMetaObjects by instantiating QML types and running |