Commit d48756d7 authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmljsInterpreter: avoid ambiguities about major import version

Both CppComponentValues are created and available in the code model.
In case of a context lookup it seems to be random which one is taken.

This patch ensures that the code model only contains the object
with the highest version.

Change-Id: Icd1ac1c7d62e277bbd8a2747c3504457be5dd8d6
Reviewed-by: default avatarChristian Kamm <>
parent a90abe9e
......@@ -1358,7 +1358,8 @@ template void CppQmlTypes::load< QHash<QString, FakeMetaObject::ConstPtr> >(cons
QList<const CppComponentValue *> CppQmlTypes::createObjectsForImport(const QString &package, ComponentVersion version)
QList<const CppComponentValue *> exportedObjects;
QHash<QString, const CppComponentValue *> exportedObjects;
QList<const CppComponentValue *> newObjects;
// make new exported objects
......@@ -1398,8 +1399,11 @@ QList<const CppComponentValue *> CppQmlTypes::createObjectsForImport(const QStri
// use package.cppname importversion as key
_objectsByQualifiedName.insert(key, newComponent);
if (exported)
exportedObjects += newComponent;
if (exported) {
if (!exportedObjects.contains(name) // we might have the same type in different versions
|| (newComponent->componentVersion() > exportedObjects.value(name)->componentVersion()))
exportedObjects.insert(name, newComponent);
newObjects += newComponent;
......@@ -1437,7 +1441,7 @@ QList<const CppComponentValue *> CppQmlTypes::createObjectsForImport(const QStri
return exportedObjects;
return exportedObjects.values();
bool CppQmlTypes::hasModule(const QString &module) const
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