summaryrefslogtreecommitdiff
path: root/src/plugins/vcsbase
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2019-08-16 09:57:59 +0200
committerTobias Hunger <tobias.hunger@qt.io>2019-08-19 14:27:06 +0000
commitd272a64eab51a1017d1a81b71512e2135f51ce93 (patch)
treeb1d012ab53bd4bf55010834d5809b0ba56a7dd64 /src/plugins/vcsbase
parent109a8b18292b3c1263b88e610fe7f9724eed2bd8 (diff)
downloadqt-creator-d272a64eab51a1017d1a81b71512e2135f51ce93.tar.gz
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 <christian.kandeler@qt.io>
Diffstat (limited to 'src/plugins/vcsbase')
-rw-r--r--src/plugins/vcsbase/vcsbaseeditor.cpp14
1 files changed, 4 insertions, 10 deletions
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<ProjectExplorer::Project*> 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)