Nim: Simplified project scan by removing QFutureInterface

Change-Id: I60a0d3354083215661def0acd4c26c1ece00dea7
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Filippo Cucchetto
2016-12-03 12:41:44 +01:00
parent dfaf01614d
commit 3d8f42097b
2 changed files with 7 additions and 15 deletions

View File

@@ -65,7 +65,6 @@ NimProject::NimProject(NimProjectManager *projectManager, const QString &fileNam
m_projectScanTimer.setSingleShot(true);
connect(&m_projectScanTimer, &QTimer::timeout, this, &NimProject::collectProjectFiles);
m_futureWatcher.setFuture(m_futureInterface.future());
connect(&m_futureWatcher, &QFutureWatcher<QList<FileNode *>>::finished, this, &NimProject::updateProject);
collectProjectFiles();
@@ -102,19 +101,13 @@ void NimProject::scheduleProjectScan()
void NimProject::collectProjectFiles()
{
m_lastProjectScan.start();
QTC_ASSERT(!m_futureInterface.isRunning(), return);
runAsync([this]() {
m_futureInterface.reportStarted();
QList<FileNode *> nodes
= FileNode::scanForFiles(projectDirectory(),
[](const FileName &fn) { return new FileNode(fn, FileType::Source, false); },
&m_futureInterface);
m_futureInterface.setProgressValue(m_futureInterface.progressMaximum());
m_futureInterface.reportResult(nodes);
m_futureInterface.reportFinished();
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); });
});
Core::ProgressManager::addTask(m_futureInterface.future(), tr("Scanning for Nim files"), "Nim.Project.Scan");
m_futureWatcher.setFuture(future);
Core::ProgressManager::addTask(future, tr("Scanning for Nim files"), "Nim.Project.Scan");
}
void NimProject::updateProject()
@@ -122,7 +115,7 @@ void NimProject::updateProject()
QStringList oldFiles = m_files;
m_files.clear();
QList<FileNode *> fileNodes = Utils::filtered(m_futureInterface.future().result(),
QList<FileNode *> fileNodes = Utils::filtered(m_futureWatcher.future().result(),
[](const FileNode *fn) {
const QString fileName = fn->filePath().fileName();
return !fileName.endsWith(".nimproject", HostOsInfo::fileNameCaseSensitivity())

View File

@@ -59,7 +59,6 @@ private:
void updateProject();
QStringList m_files;
QFutureInterface<QList<ProjectExplorer::FileNode *>> m_futureInterface;
QFutureWatcher<QList<ProjectExplorer::FileNode *>> m_futureWatcher;
QElapsedTimer m_lastProjectScan;