From d272a64eab51a1017d1a81b71512e2135f51ce93 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Fri, 16 Aug 2019 09:57:59 +0200 Subject: Project: Remove Project::document() method The document is used to do file watching, which may or may not be ideal. So make sure we do not leak the information how we watch files into the API and its users. The method is not used sensibly anywhere in creator, so it seems safe to remove it entirely. Change-Id: Ieed755bd5c852875378e4e96665dc906499975b0 Reviewed-by: Christian Kandeler --- src/plugins/vcsbase/vcsbaseeditor.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'src/plugins/vcsbase') diff --git a/src/plugins/vcsbase/vcsbaseeditor.cpp b/src/plugins/vcsbase/vcsbaseeditor.cpp index fee6dbc72c..aaf677063b 100644 --- a/src/plugins/vcsbase/vcsbaseeditor.cpp +++ b/src/plugins/vcsbase/vcsbaseeditor.cpp @@ -1246,19 +1246,13 @@ static QTextCodec *findFileCodec(const QString &source) // Find the codec by checking the projects (root dir of project file) static QTextCodec *findProjectCodec(const QString &dir) { + const FilePath dirPath = FilePath::fromString(dir); typedef QList ProjectList; // Try to find a project under which file tree the file is. const ProjectList projects = ProjectExplorer::SessionManager::projects(); - if (!projects.empty()) { - const ProjectList::const_iterator pcend = projects.constEnd(); - for (ProjectList::const_iterator it = projects.constBegin(); it != pcend; ++it) - if (const Core::IDocument *document = (*it)->document()) - if (document->filePath().toString().startsWith(dir)) { - QTextCodec *codec = (*it)->editorConfiguration()->textCodec(); - return codec; - } - } - return nullptr; + const ProjectExplorer::Project *p + = findOrDefault(projects, equal(&ProjectExplorer::Project::projectDirectory, dirPath)); + return p ? p->editorConfiguration()->textCodec() : nullptr; } QTextCodec *VcsBaseEditor::getCodec(const QString &source) -- cgit v1.2.1