diff options
author | Fawzi Mohamed <fawzi.mohamed@digia.com> | 2014-12-02 13:24:25 +0100 |
---|---|---|
committer | Fawzi Mohamed <fawzi.mohamed@theqtcompany.com> | 2014-12-03 11:53:50 +0100 |
commit | cfe29cc936cf951e16a67295c16e2edd561a187b (patch) | |
tree | 8f5f452ebfe984ac41a1abf2154f24b065446643 | |
parent | ecfe8329eb16d1c9cef3efe4f8fa10a81e6ed612 (diff) | |
download | qt-creator-cfe29cc936cf951e16a67295c16e2edd561a187b.tar.gz |
qmljs: fix projectInfoForPath and fileToPath mapping
m_fileToPath was not always updated correctly which lead
projectInfoForPath to return a wrong/invalid project info,
messing up the paths used by the code model.
Change-Id: If5e144f1ef2c7353b9077deb1b9c9aa9d1708651
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@theqtcompany.com>
-rw-r--r-- | src/libs/qmljs/qmljsmodelmanagerinterface.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp index dd7491eefa..64b2a4331d 100644 --- a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp +++ b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp @@ -563,9 +563,9 @@ void ModelManagerInterface::updateProjectInfo(const ProjectInfo &pinfo, ProjectE if (!snapshot.document(file)) newFiles += file; } - updateSourceFiles(newFiles, false); - foreach (const QString &newFile, deletedFiles) + foreach (const QString &newFile, newFiles) m_fileToProject.insert(newFile, p); + updateSourceFiles(newFiles, false); // update qrc cache foreach (const QString &newQrc, pinfo.allResourceFiles) @@ -608,6 +608,10 @@ ModelManagerInterface::ProjectInfo ModelManagerInterface::projectInfoForPath(QSt { QMutexLocker locker(&m_mutex); projects = m_fileToProject.values(path); + if (projects.isEmpty()) { + QFileInfo fInfo(path); + projects = m_fileToProject.values(fInfo.canonicalFilePath()); + } } QList<ProjectInfo> infos; foreach (ProjectExplorer::Project *project, projects) { @@ -616,6 +620,7 @@ ModelManagerInterface::ProjectInfo ModelManagerInterface::projectInfoForPath(QSt infos.append(info); } std::sort(infos.begin(), infos.end(), &pInfoLessThanImports); + infos.append(m_defaultProjectInfo); ProjectInfo res; foreach (const ProjectInfo &pInfo, infos) { @@ -1321,7 +1326,7 @@ ModelManagerInterface::CppDataHash ModelManagerInterface::cppData() const LibraryInfo ModelManagerInterface::builtins(const Document::Ptr &doc) const { - ProjectInfo info = projectInfoForPath(doc->path()); + ProjectInfo info = projectInfoForPath(doc->fileName()); if (!info.isValid()) return LibraryInfo(); if (!info.qtQmlPath.isEmpty()) @@ -1343,7 +1348,7 @@ ViewerContext ModelManagerInterface::completeVContext(const ViewerContext &vCtx, res.language = doc->language(); ProjectInfo info; if (!doc.isNull()) - info = projectInfoForPath(doc->path()); + info = projectInfoForPath(doc->fileName()); ViewerContext defaultVCtx = defaultVContext(res.language, Document::Ptr(0), false); ProjectInfo defaultInfo = defaultProjectInfo(); if (info.qtImportsPath.isEmpty()) |