From d48756d75b41ac3d598d9cb9a90990621a8f7dd5 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Tue, 25 Sep 2012 11:42:24 +0200 Subject: [PATCH] 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 --- src/libs/qmljs/qmljsinterpreter.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/libs/qmljs/qmljsinterpreter.cpp b/src/libs/qmljs/qmljsinterpreter.cpp index 2736fde9ccd..c47764ca012 100644 --- a/src/libs/qmljs/qmljsinterpreter.cpp +++ b/src/libs/qmljs/qmljsinterpreter.cpp @@ -1358,7 +1358,8 @@ template void CppQmlTypes::load< QHash >(cons QList CppQmlTypes::createObjectsForImport(const QString &package, ComponentVersion version) { - QList exportedObjects; + QHash exportedObjects; + QList newObjects; // make new exported objects @@ -1398,8 +1399,11 @@ QList 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 CppQmlTypes::createObjectsForImport(const QStri } } - return exportedObjects; + return exportedObjects.values(); } bool CppQmlTypes::hasModule(const QString &module) const