diff --git a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp
index dd7491eefaa3a1ddfaac3e9d6040f73eb9bf221e..64b2a4331d08f18d051151f411c0b555b47e6c4c 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())