Commit d4c2c3f2 authored by Aurindam Jana's avatar Aurindam Jana
Browse files

QmlJSInterpreter: QML Plugin types

A Component in .qmltypes can have an array of exports which
may differ in type names and versions.
Consider the type names to be aliases and create a CppComponentValue
for each of the alias corresponding to the best available version.

Change-Id: I759ae0c68441e805b0502bf2d203c524bf1a7a7c
Reviewed-by: default avatarFawzi Mohamed <>
parent 72bf41b4
......@@ -1365,19 +1365,20 @@ QList<const CppComponentValue *> CppQmlTypes::createObjectsForImport(const QStri
// make new exported objects
foreach (const FakeMetaObject::ConstPtr &fmo, _fakeMetaObjectsByPackage.value(package)) {
// find the highest-version export
FakeMetaObject::Export bestExport;
QList<QString> aliases;
// find the highest-version export for each alias
QHash<QString, FakeMetaObject::Export> bestExports;
foreach (const FakeMetaObject::Export &exp, fmo->exports()) {
// Store all aliases
if (!exp.type.isEmpty() && !aliases.contains(exp.type))
if (exp.package != package || (version.isValid() && exp.version > version))
if (!bestExport.isValid() || exp.version > bestExport.version)
bestExport = exp;
if (bestExports.contains(exp.type)) {
if (exp.version > bestExports.value(exp.type).version)
bestExports.insert(exp.type, exp);
} else {
bestExports.insert(exp.type, exp);
if (!bestExport.isValid())
if (bestExports.isEmpty())
// if it already exists, skip
......@@ -1385,6 +1386,7 @@ QList<const CppComponentValue *> CppQmlTypes::createObjectsForImport(const QStri
if (_objectsByQualifiedName.contains(key))
foreach (const FakeMetaObject::Export &bestExport, bestExports) {
QString name = bestExport.type;
bool exported = true;
if (name.isEmpty()) {
......@@ -1398,21 +1400,10 @@ QList<const CppComponentValue *> CppQmlTypes::createObjectsForImport(const QStri
// use package.cppname importversion as key
_objectsByQualifiedName.insert(key, newComponent);
// Create CppComponentValues for all the aliases
// TODO: Show warning for deprecated ones
QList<const CppComponentValue *> newComponents;
foreach (const QString &alias, aliases) {
newComponents.append(new CppComponentValue(
fmo, alias, package, bestExport.version, version,
bestExport.metaObjectRevision, _valueOwner));
if (exported)
exportedObjects += newComponents;
newObjects += newComponents;
exportedObjects += newComponent;
newObjects += newComponent;
// set their prototypes, creating them if necessary
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment