ProjectExplorer: Do not use version manager cache in threads

Do not use VcsManager's cache of version control systems from different
threads.

Iterate over all IVersionControls instead of getting the specific version
control for a directory. This is less exact, but will probably not hurt users.

Task-number: QTCREATORBUG-18258
Change-Id: Iae2be5735a0d7ecc8d774904f6681963fca1d114
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Tobias Hunger
2017-06-19 16:07:25 +02:00
parent e42f3db9f0
commit bc22de5f0a
6 changed files with 55 additions and 17 deletions

View File

@@ -31,6 +31,8 @@
#include "../nimconstants.h"
#include <coreplugin/progressmanager/progressmanager.h>
#include <coreplugin/iversioncontrol.h>
#include <coreplugin/vcsmanager.h>
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/kit.h>
#include <projectexplorer/projectexplorerconstants.h>
@@ -113,8 +115,11 @@ void NimProject::collectProjectFiles()
m_lastProjectScan.start();
QTC_ASSERT(!m_futureWatcher.future().isRunning(), return);
FileName prjDir = projectDirectory();
QFuture<QList<ProjectExplorer::FileNode *>> future = Utils::runAsync([prjDir] {
return FileNode::scanForFiles(prjDir, [](const FileName &fn) { return new FileNode(fn, FileType::Source, false); });
const QList<Core::IVersionControl *> versionControls = Core::VcsManager::versionControls();
QFuture<QList<ProjectExplorer::FileNode *>> future = Utils::runAsync([prjDir, versionControls] {
return FileNode::scanForFilesWithVersionControls(
prjDir, [](const FileName &fn) { return new FileNode(fn, FileType::Source, false); },
versionControls);
});
m_futureWatcher.setFuture(future);
Core::ProgressManager::addTask(future, tr("Scanning for Nim files"), "Nim.Project.Scan");