diff options
author | Marco Benelli <[email protected]> | 2016-06-23 10:48:54 +0200 |
---|---|---|
committer | Marco Benelli <[email protected]> | 2016-06-23 11:55:42 +0000 |
commit | 8f474cbfbee1d805b7363849c37467d4e30ceb6c (patch) | |
tree | 35096dbdecdb2ec1266153ce05a50726282de7d5 /src/libs/qmljs/qmljsutils.cpp | |
parent | 8562abbb567c21e34d222c6dc024b4a3f046521f (diff) |
QmlJs: fixes bug in module import search.
Task-number: QTCREATORBUG-16425
Change-Id: I5fdd1a5882730c0f52dba5edb8cf8ca7092a4409
Reviewed-by: Erik Verbruggen <[email protected]>
Diffstat (limited to 'src/libs/qmljs/qmljsutils.cpp')
-rw-r--r-- | src/libs/qmljs/qmljsutils.cpp | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/src/libs/qmljs/qmljsutils.cpp b/src/libs/qmljs/qmljsutils.cpp index 8f87b2c98fa..e91db31b360 100644 --- a/src/libs/qmljs/qmljsutils.cpp +++ b/src/libs/qmljs/qmljsutils.cpp @@ -250,24 +250,28 @@ QString QmlJS::modulePath(const QString &name, const QString &version, QString candidate; - for (QString ver = sanitizedVersion; ; ver.remove(re)) { + for (QString ver = sanitizedVersion; !ver.isEmpty(); ver.remove(re)) { for (const QString &path: importPaths) { - if (ver.isEmpty()) { - candidate = QDir::cleanPath(QString::fromLatin1("%1/%2").arg(path, mkpath(parts))); - return QDir(candidate).exists() ? candidate : QString(); - } else { - for (int i = parts.count() - 1; i >= 0; --i) { - candidate = QDir::cleanPath( - QString::fromLatin1("%1/%2.%3/%4").arg(path, - mkpath(parts.mid(0, i + 1)), - ver, - mkpath(parts.mid(i + 1)))); - if (QDir(candidate).exists()) - return candidate; - } + for (int i = parts.count() - 1; i >= 0; --i) { + candidate = QDir::cleanPath( + QString::fromLatin1("%1/%2.%3/%4").arg(path, + mkpath(parts.mid(0, i + 1)), + ver, + mkpath(parts.mid(i + 1)))); + if (QDir(candidate).exists()) + return candidate; } } } + + // Version is empty + for (const QString &path: importPaths) { + candidate = QDir::cleanPath(QString::fromLatin1("%1/%2").arg(path, mkpath(parts))); + if (QDir(candidate).exists()) + return candidate; + } + + return QString(); } bool QmlJS::isValidBuiltinPropertyType(const QString &name) |