forked from qt-creator/qt-creator
Don't update extra compilers individually after project load
Each call of CppModelManager::updateSourceFiles detaches the current snapshot. The extra compilers where set up and triggered individually, and resulted in individual updateSourceFiles calls with the single result file of the extra compiler. For Qt Creator this would lead to 200 calls in quick succession after project load, potentially leading to a freeze of multiple seconds. Instead of updating the result files of the extra compilers individually after project load, integrate the update into the regular project source file update. So we end up with only a single call of updateSourceFiles. For this the project updater needs to trigger the extra compilers, and wait for all to finish as well as the regular project part update, before triggering the parser. Task-number: QTCREATORBUG-25783 Change-Id: I34f6df0fc0f96bcb42ee65019bee39cf49176c1f Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -123,11 +123,6 @@ ExtraCompiler::ExtraCompiler(const Project *project, const Utils::FilePath &sour
|
||||
if (file.open(QFile::ReadOnly | QFile::Text))
|
||||
setContent(target, file.readAll());
|
||||
}
|
||||
|
||||
if (d->dirty) {
|
||||
d->dirty = false;
|
||||
QTimer::singleShot(0, this, [this]() { run(d->source); }); // delay till available.
|
||||
}
|
||||
}
|
||||
|
||||
ExtraCompiler::~ExtraCompiler() = default;
|
||||
@@ -173,6 +168,11 @@ QThreadPool *ExtraCompiler::extraCompilerThreadPool()
|
||||
return s_extraCompilerThreadPool();
|
||||
}
|
||||
|
||||
bool ExtraCompiler::isDirty() const
|
||||
{
|
||||
return d->dirty;
|
||||
}
|
||||
|
||||
void ExtraCompiler::onTargetsBuilt(Project *project)
|
||||
{
|
||||
if (project != d->project || BuildManager::isBuilding(project))
|
||||
@@ -346,15 +346,16 @@ void ProcessExtraCompiler::run(const QByteArray &sourceContents)
|
||||
runImpl(contents);
|
||||
}
|
||||
|
||||
void ProcessExtraCompiler::run(const Utils::FilePath &fileName)
|
||||
QFuture<FileNameToContentsHash> ProcessExtraCompiler::run()
|
||||
{
|
||||
const Utils::FilePath fileName = source();
|
||||
ContentProvider contents = [fileName]() {
|
||||
QFile file(fileName.toString());
|
||||
if (!file.open(QFile::ReadOnly | QFile::Text))
|
||||
return QByteArray();
|
||||
return file.readAll();
|
||||
};
|
||||
runImpl(contents);
|
||||
return runImpl(contents);
|
||||
}
|
||||
|
||||
Utils::FilePath ProcessExtraCompiler::workingDirectory() const
|
||||
@@ -379,7 +380,7 @@ Tasks ProcessExtraCompiler::parseIssues(const QByteArray &stdErr)
|
||||
return {};
|
||||
}
|
||||
|
||||
void ProcessExtraCompiler::runImpl(const ContentProvider &provider)
|
||||
QFuture<FileNameToContentsHash> ProcessExtraCompiler::runImpl(const ContentProvider &provider)
|
||||
{
|
||||
if (m_watcher)
|
||||
delete m_watcher;
|
||||
@@ -392,6 +393,7 @@ void ProcessExtraCompiler::runImpl(const ContentProvider &provider)
|
||||
&ProcessExtraCompiler::runInThread, this,
|
||||
command(), workingDirectory(), arguments(), provider,
|
||||
buildEnvironment()));
|
||||
return m_watcher->future();
|
||||
}
|
||||
|
||||
void ProcessExtraCompiler::runInThread(
|
||||
|
||||
Reference in New Issue
Block a user