From cbc5f22b3b79b7752a3af805acd18172ae4ce8f8 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Wed, 4 May 2016 12:54:47 +0200 Subject: [PATCH] QmlJS: Allow version in parent module Task-number: QTCREATORBUG-16145 Change-Id: I5ddbbab1c808f422ebcec1502f9b50a9bf0babb6 Reviewed-by: Marco Benelli Reviewed-by: Eike Ziller Reviewed-by: Alessandro Portale --- src/libs/qmljs/qmljslink.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/libs/qmljs/qmljslink.cpp b/src/libs/qmljs/qmljslink.cpp index f46b228547b..1edfd1c723c 100644 --- a/src/libs/qmljs/qmljslink.cpp +++ b/src/libs/qmljs/qmljslink.cpp @@ -410,6 +410,24 @@ Import LinkPrivate::importNonFile(Document::Ptr doc, const ImportInfo &importInf } } + //The version number can be located higher in the path: qml/QtQuick.Controls.2/Material + if (!importFound) { + foreach (const QString &importPath, importPaths) { + QStringList splittedList = packagePath.split(QLatin1String("/")); + const QString last = splittedList.last(); + splittedList.removeLast(); + QString libraryPath = QString::fromLatin1("%1/%2.%3/%4").arg(importPath, + splittedList.join(QLatin1String("/")), + QString::number(version.majorVersion()), + last); + if (importLibrary(doc, libraryPath, &import, importPath)) { + importFound = true; + break; + } + } + + } + // if there are cpp-based types for this package, use them too if (valueOwner->cppQmlTypes().hasModule(packageName)) { importFound = true;