Commit 9e62375b authored by Kai Koehne's avatar Kai Koehne
Browse files

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: default avatarFawzi Mohamed <fawzi.mohamed@digia.com>
parent ba558bc2
......@@ -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;
......
......@@ -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;
......
......@@ -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();
......
......@@ -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());
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment