forked from qt-creator/qt-creator
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: Christian Kamm <kamm@incasoftware.de>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user