forked from qt-creator/qt-creator
		
	C++: handle case-insensitive file names for project files.
... by keying on Utils::FileName. Task-number: QTCREATORBUG-12390 Change-Id: Ib99eefcf3440d4383f624a614a3093f427efffbd Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
		
				
					committed by
					
						
						Erik Verbruggen
					
				
			
			
				
	
			
			
			
						parent
						
							5a40c071a4
						
					
				
				
					commit
					7d377850d0
				
			@@ -130,7 +130,7 @@ void BaseEditorDocumentParser::updateProjectPart()
 | 
			
		||||
            return;
 | 
			
		||||
 | 
			
		||||
        // Fall-back step 1: Get some parts through the dependency table:
 | 
			
		||||
        projectParts = cmm->projectPartFromDependencies(m_filePath);
 | 
			
		||||
        projectParts = cmm->projectPartFromDependencies(Utils::FileName::fromString(m_filePath));
 | 
			
		||||
        if (projectParts.isEmpty())
 | 
			
		||||
            // Fall-back step 2: Use fall-back part from the model manager:
 | 
			
		||||
            m_projectPart = cmm->fallbackProjectPart();
 | 
			
		||||
 
 | 
			
		||||
@@ -49,6 +49,7 @@
 | 
			
		||||
#include <projectexplorer/projectexplorer.h>
 | 
			
		||||
#include <projectexplorer/session.h>
 | 
			
		||||
#include <extensionsystem/pluginmanager.h>
 | 
			
		||||
#include <utils/fileutils.h>
 | 
			
		||||
#include <utils/qtcassert.h>
 | 
			
		||||
 | 
			
		||||
#include <QCoreApplication>
 | 
			
		||||
@@ -129,7 +130,7 @@ public:
 | 
			
		||||
    // Project integration
 | 
			
		||||
    mutable QMutex m_projectMutex;
 | 
			
		||||
    QMap<ProjectExplorer::Project *, ProjectInfo> m_projectToProjectsInfo;
 | 
			
		||||
    QMap<QString, QList<CppTools::ProjectPart::Ptr> > m_fileToProjectParts;
 | 
			
		||||
    QMap<Utils::FileName, QList<CppTools::ProjectPart::Ptr> > m_fileToProjectParts;
 | 
			
		||||
    QMap<QString, CppTools::ProjectPart::Ptr> m_projectFileToProjectPart;
 | 
			
		||||
    // The members below are cached/(re)calculated from the projects and/or their project parts
 | 
			
		||||
    bool m_dirty;
 | 
			
		||||
@@ -686,7 +687,8 @@ void CppModelManager::recalculateFileToProjectParts()
 | 
			
		||||
        foreach (const ProjectPart::Ptr &projectPart, projectInfo.projectParts()) {
 | 
			
		||||
            d->m_projectFileToProjectPart[projectPart->projectFile] = projectPart;
 | 
			
		||||
            foreach (const ProjectFile &cxxFile, projectPart->files)
 | 
			
		||||
                d->m_fileToProjectParts[cxxFile.path].append(projectPart);
 | 
			
		||||
                d->m_fileToProjectParts[Utils::FileName::fromString(cxxFile.path)].append(
 | 
			
		||||
                            projectPart);
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@@ -805,21 +807,21 @@ ProjectPart::Ptr CppModelManager::projectPartForProjectFile(const QString &proje
 | 
			
		||||
    return d->m_projectFileToProjectPart.value(projectFile);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QList<ProjectPart::Ptr> CppModelManager::projectPart(const QString &fileName) const
 | 
			
		||||
QList<ProjectPart::Ptr> CppModelManager::projectPart(const Utils::FileName &fileName) const
 | 
			
		||||
{
 | 
			
		||||
    QMutexLocker locker(&d->m_projectMutex);
 | 
			
		||||
    return d->m_fileToProjectParts.value(fileName);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QList<ProjectPart::Ptr> CppModelManager::projectPartFromDependencies(const QString &fileName) const
 | 
			
		||||
QList<ProjectPart::Ptr> CppModelManager::projectPartFromDependencies(
 | 
			
		||||
        const Utils::FileName &fileName) const
 | 
			
		||||
{
 | 
			
		||||
    QSet<ProjectPart::Ptr> parts;
 | 
			
		||||
    const Utils::FileNameList deps = snapshot().filesDependingOn(fileName);
 | 
			
		||||
 | 
			
		||||
    QMutexLocker locker(&d->m_projectMutex);
 | 
			
		||||
    foreach (const Utils::FileName &dep, deps) {
 | 
			
		||||
        parts.unite(QSet<ProjectPart::Ptr>::fromList(
 | 
			
		||||
                        d->m_fileToProjectParts.value(dep.toString())));
 | 
			
		||||
        parts.unite(QSet<ProjectPart::Ptr>::fromList(d->m_fileToProjectParts.value(dep)));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return parts.values();
 | 
			
		||||
 
 | 
			
		||||
@@ -96,10 +96,12 @@ public:
 | 
			
		||||
    /// \return The project part with the given project file
 | 
			
		||||
    ProjectPart::Ptr projectPartForProjectFile(const QString &projectFile) const;
 | 
			
		||||
    /// \return All project parts that mention the given file name as one of the sources/headers.
 | 
			
		||||
    QList<ProjectPart::Ptr> projectPart(const QString &fileName) const;
 | 
			
		||||
    QList<ProjectPart::Ptr> projectPart(const Utils::FileName &fileName) const;
 | 
			
		||||
    QList<ProjectPart::Ptr> projectPart(const QString &fileName) const
 | 
			
		||||
    { return projectPart(Utils::FileName::fromString(fileName)); }
 | 
			
		||||
    /// This is a fall-back function: find all files that includes the file directly or indirectly,
 | 
			
		||||
    /// and return its \c ProjectPart list for use with this file.
 | 
			
		||||
    QList<ProjectPart::Ptr> projectPartFromDependencies(const QString &fileName) const;
 | 
			
		||||
    QList<ProjectPart::Ptr> projectPartFromDependencies(const Utils::FileName &fileName) const;
 | 
			
		||||
    /// \return A synthetic \c ProjectPart which consists of all defines/includes/frameworks from
 | 
			
		||||
    ///         all loaded projects.
 | 
			
		||||
    ProjectPart::Ptr fallbackProjectPart() const;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user