Project: Delay acting on fileListChanged signal

This gives the UI a bit more opportunity to render after the project was
parsed.

Change-Id: Ie316f1c69cb0ebb856943a094b81b55f1aa2317a
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Tobias Hunger
2019-06-18 16:22:42 +02:00
parent d6d133da42
commit a3d6839162
4 changed files with 23 additions and 7 deletions

View File

@@ -43,6 +43,7 @@
#include <coreplugin/messagemanager.h> #include <coreplugin/messagemanager.h>
#include <cppeditor/cppeditorconstants.h> #include <cppeditor/cppeditorconstants.h>
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
#include <projectexplorer/projectnodes.h>
#include <projectexplorer/projecttree.h> #include <projectexplorer/projecttree.h>
#include <texteditor/formattexteditor.h> #include <texteditor/formattexteditor.h>
#include <texteditor/textdocument.h> #include <texteditor/textdocument.h>
@@ -50,13 +51,13 @@
#include <texteditor/texteditor.h> #include <texteditor/texteditor.h>
#include <texteditor/texteditorconstants.h> #include <texteditor/texteditorconstants.h>
#include <utils/algorithm.h> #include <utils/algorithm.h>
#include <utils/textutils.h>
#include <utils/fileutils.h> #include <utils/fileutils.h>
#include <utils/mimetypes/mimedatabase.h> #include <utils/mimetypes/mimedatabase.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/runextensions.h> #include <utils/runextensions.h>
#include <utils/synchronousprocess.h> #include <utils/synchronousprocess.h>
#include <utils/temporarydirectory.h> #include <utils/temporarydirectory.h>
#include <utils/textutils.h>
#include <QDir> #include <QDir>
#include <QFileInfo> #include <QFileInfo>
@@ -161,7 +162,12 @@ void BeautifierPluginPrivate::autoFormatOnSave(Core::IDocument *document)
// Check if file is contained in the current project (if wished) // Check if file is contained in the current project (if wished)
if (m_generalSettings->autoFormatOnlyCurrentProject()) { if (m_generalSettings->autoFormatOnlyCurrentProject()) {
const ProjectExplorer::Project *pro = ProjectExplorer::ProjectTree::currentProject(); const ProjectExplorer::Project *pro = ProjectExplorer::ProjectTree::currentProject();
if (!pro || !pro->isKnownFile(document->filePath())) { if (!pro
|| pro->files([document](const ProjectExplorer::Node *n) {
return ProjectExplorer::Project::SourceFiles(n)
&& n->filePath() == document->filePath();
})
.isEmpty()) {
return; return;
} }
} }

View File

@@ -56,7 +56,11 @@ void ResourceHandler::ensureInitialized()
m_initialized = true; m_initialized = true;
auto connector = [this](Project *p) { auto connector = [this](Project *p) {
connect(p, &Project::fileListChanged, this, &ResourceHandler::updateResources); connect(p,
&Project::fileListChanged,
this,
&ResourceHandler::updateResources,
Qt::QueuedConnection);
}; };
for (Project *p : SessionManager::projects()) for (Project *p : SessionManager::projects())

View File

@@ -370,8 +370,11 @@ QString ModelIndexer::findDiagram(const qmt::Uid &modelUid, const qmt::Uid &diag
void ModelIndexer::onProjectAdded(ProjectExplorer::Project *project) void ModelIndexer::onProjectAdded(ProjectExplorer::Project *project)
{ {
connect(project, &ProjectExplorer::Project::fileListChanged, connect(project,
this, [=]() { this->onProjectFileListChanged(project); }); &ProjectExplorer::Project::fileListChanged,
this,
[=]() { this->onProjectFileListChanged(project); },
Qt::QueuedConnection);
scanProject(project); scanProject(project);
} }

View File

@@ -89,8 +89,11 @@ QtOutputFormatter::QtOutputFormatter(Project *project)
d->projectFinder.setProjectFiles(project->files(Project::SourceFiles)); d->projectFinder.setProjectFiles(project->files(Project::SourceFiles));
d->projectFinder.setProjectDirectory(project->projectDirectory()); d->projectFinder.setProjectDirectory(project->projectDirectory());
connect(project, &Project::fileListChanged, connect(project,
this, &QtOutputFormatter::updateProjectFileList); &Project::fileListChanged,
this,
&QtOutputFormatter::updateProjectFileList,
Qt::QueuedConnection);
} }
} }