summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@digia.com>2014-09-02 14:42:51 +0200
committerKai Koehne <kai.koehne@digia.com>2014-09-03 09:41:48 +0200
commit9e62375b71cf32e9deebb8815c14bb0a2346747e (patch)
treed318e86ce90fc38d8fa636a7cef3150706324a2b
parentba558bc2a2abb342b014fb349a2a32e53cafcad7 (diff)
downloadqt-creator-9e62375b71cf32e9deebb8815c14bb0a2346747e.tar.gz
QmlJS: Use canonical paths for matching of import directories
We rely on string comparison for detection of QML import paths. Therefore make sure that all paths are canonical. Change-Id: I416bc31915644a888c416d726049668b0e71f29a Task-number: QTCREATORBUG-12902 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
-rw-r--r--src/libs/qmljs/qmljsdocument.cpp1
-rw-r--r--src/libs/qmljs/qmljslink.cpp16
-rw-r--r--src/libs/qmljs/qmljsmodelmanagerinterface.cpp6
-rw-r--r--src/plugins/qmljstools/qmljsmodelmanager.cpp8
4 files changed, 20 insertions, 11 deletions
diff --git a/src/libs/qmljs/qmljsdocument.cpp b/src/libs/qmljs/qmljsdocument.cpp
index cf7fd70bd1..cb1b9c52c7 100644
--- a/src/libs/qmljs/qmljsdocument.cpp
+++ b/src/libs/qmljs/qmljsdocument.cpp
@@ -534,6 +534,7 @@ void Snapshot::insert(const Document::Ptr &document, bool allowInvalid)
void Snapshot::insertLibraryInfo(const QString &path, const LibraryInfo &info)
{
+ QTC_CHECK(!path.isEmpty());
QTC_CHECK(info.fingerprint() == info.calculateFingerprint());
_libraries.insert(QDir::cleanPath(path), info);
if (!info.wasFound()) return;
diff --git a/src/libs/qmljs/qmljslink.cpp b/src/libs/qmljs/qmljslink.cpp
index 50746e0a76..ede1022f20 100644
--- a/src/libs/qmljs/qmljslink.cpp
+++ b/src/libs/qmljs/qmljslink.cpp
@@ -438,15 +438,21 @@ Import LinkPrivate::importNonFile(Document::Ptr doc, const ImportInfo &importInf
}
bool LinkPrivate::importLibrary(Document::Ptr doc,
- const QString &libraryPath,
+ const QString &libraryPath_,
Import *import,
const QString &importPath)
{
const ImportInfo &importInfo = import->info;
-
- const LibraryInfo libraryInfo = snapshot.libraryInfo(libraryPath);
- if (!libraryInfo.isValid())
- return false;
+ QString libraryPath = libraryPath_;
+
+ LibraryInfo libraryInfo = snapshot.libraryInfo(libraryPath);
+ if (!libraryInfo.isValid()) {
+ // try canonical path
+ libraryPath = QFileInfo(libraryPath).canonicalFilePath();
+ libraryInfo = snapshot.libraryInfo(libraryPath);
+ if (!libraryInfo.isValid())
+ return false;
+ }
import->libraryPath = libraryPath;
diff --git a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp
index 281e7461c5..a9f7adf64e 100644
--- a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp
+++ b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp
@@ -114,9 +114,11 @@ ModelManagerInterface::ModelManagerInterface(QObject *parent)
qRegisterMetaType<QmlJS::Document::Ptr>("QmlJS::Document::Ptr");
qRegisterMetaType<QmlJS::LibraryInfo>("QmlJS::LibraryInfo");
- m_defaultProjectInfo.qtImportsPath = QLibraryInfo::location(QLibraryInfo::ImportsPath);
+ m_defaultProjectInfo.qtImportsPath = QFileInfo(
+ QLibraryInfo::location(QLibraryInfo::ImportsPath)).canonicalFilePath();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
- m_defaultProjectInfo.qtQmlPath = QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath);
+ m_defaultProjectInfo.qtQmlPath = QFileInfo(
+ QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath)).canonicalFilePath();
#endif
m_defaultImportPaths << environmentImportPaths();
diff --git a/src/plugins/qmljstools/qmljsmodelmanager.cpp b/src/plugins/qmljstools/qmljsmodelmanager.cpp
index 3c5a53806d..802765c540 100644
--- a/src/plugins/qmljstools/qmljsmodelmanager.cpp
+++ b/src/plugins/qmljstools/qmljsmodelmanager.cpp
@@ -112,14 +112,14 @@ ModelManagerInterface::ProjectInfo QmlJSTools::defaultProjectInfoForProject(
projectInfo.tryQmlDump = project && (
qtVersion->type() == QLatin1String(QtSupport::Constants::DESKTOPQT)
|| qtVersion->type() == QLatin1String(QtSupport::Constants::SIMULATORQT));
- projectInfo.qtQmlPath = qtVersion->qmakeProperty("QT_INSTALL_QML");
- projectInfo.qtImportsPath = qtVersion->qmakeProperty("QT_INSTALL_IMPORTS");
+ projectInfo.qtQmlPath = QFileInfo(qtVersion->qmakeProperty("QT_INSTALL_QML")).canonicalFilePath();
+ projectInfo.qtImportsPath = QFileInfo(qtVersion->qmakeProperty("QT_INSTALL_IMPORTS")).canonicalFilePath();
projectInfo.qtVersionString = qtVersion->qtVersionString();
} else {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
- projectInfo.qtQmlPath = QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath);
+ projectInfo.qtQmlPath = QFileInfo(QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath)).canonicalFilePath();
#endif
- projectInfo.qtImportsPath = QLibraryInfo::location(QLibraryInfo::ImportsPath);
+ projectInfo.qtImportsPath = QFileInfo(QLibraryInfo::location(QLibraryInfo::ImportsPath)).canonicalFilePath();
projectInfo.qtVersionString = QLatin1String(qVersion());
}