Avoid registering individual files for watching

if we can do it en bloc. This reduces the freeze happening after loading
a project, at least on macOS with QFSEventsFileSystemWatcher, which
doesn't like getting 1000 files added one by one.

Task-number: QTCREATORBUG-25783
Change-Id: I2d508ac3334520cb8805a2179d42b86c9ba840d6
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Eike Ziller
2021-06-10 12:38:46 +02:00
parent 9915418f90
commit b29ee5493b
2 changed files with 58 additions and 46 deletions

View File

@@ -150,7 +150,6 @@ ProjectDocument::ProjectDocument(const QString &mimeType,
setFilePath(fileName);
setMimeType(mimeType);
Core::DocumentManager::addDocument(this);
}
Core::IDocument::ReloadBehavior
@@ -223,6 +222,7 @@ Project::Project(const QString &mimeType,
: d(new ProjectPrivate)
{
d->m_document = std::make_unique<ProjectDocument>(mimeType, fileName, this);
Core::DocumentManager::addDocument(d->m_document.get());
d->m_macroExpander.setDisplayName(tr("Project"));
d->m_macroExpander.registerVariable("Project:Name", tr("Project Name"),
@@ -389,16 +389,19 @@ void Project::setExtraProjectFiles(const QSet<Utils::FilePath> &projectDocumentP
for (const auto &doc : qAsConst(d->m_extraProjectDocuments))
docUpdater(doc.get());
}
QList<Core::IDocument *> toRegister;
for (const Utils::FilePath &p : toAdd) {
if (docGenerator) {
std::unique_ptr<Core::IDocument> doc = docGenerator(p);
QTC_ASSERT(doc, continue);
d->m_extraProjectDocuments.push_back(std::move(doc));
} else {
d->m_extraProjectDocuments.emplace_back(std::make_unique<ProjectDocument>(
d->m_document->mimeType(), p, this));
auto document = std::make_unique<ProjectDocument>(d->m_document->mimeType(), p, this);
toRegister.append(document.get());
d->m_extraProjectDocuments.emplace_back(std::move(document));
}
}
Core::DocumentManager::addDocuments(toRegister);
}
void Project::updateExtraProjectFiles(const QSet<Utils::FilePath> &projectDocumentPaths,