forked from qt-creator/qt-creator
QMakeProjectManager: Move some parsing code out of the UI thread
When parsing larger qmake project, the callbacks from the parser threads are currently overloading the UI thread, often rendering the application non-responsive until the project is completely loaded. This patch moves some expensive operations from the UI thread into the parser threads, at the cost of a somewhat ugly two-stage setup for some types of objects. On my Linux machine, I measured that the time spent in parser callback code went down by almost 50% when loading the Qt Creator super project. Task-number: QTCREATORBUG-18533 Change-Id: If9624da5b07e81a50c180693580b20a70e1aaea7 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -67,6 +67,7 @@
|
||||
#include <qtsupport/qtversionmanager.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/runextensions.h>
|
||||
#include <qmljs/qmljsmodelmanagerinterface.h>
|
||||
|
||||
#include <QDebug>
|
||||
@@ -710,16 +711,19 @@ QString QmakeBuildSystem::qmakeSysroot()
|
||||
|
||||
void QmakeBuildSystem::destroyProFileReader(QtSupport::ProFileReader *reader)
|
||||
{
|
||||
delete reader;
|
||||
if (!--m_qmakeGlobalsRefCnt) {
|
||||
QString dir = projectFilePath().toString();
|
||||
if (!dir.endsWith(QLatin1Char('/')))
|
||||
dir += QLatin1Char('/');
|
||||
QtSupport::ProFileCacheManager::instance()->discardFiles(dir, qmakeVfs());
|
||||
QtSupport::ProFileCacheManager::instance()->decRefCount();
|
||||
|
||||
m_qmakeGlobals.reset();
|
||||
}
|
||||
// The ProFileReader destructor is super expensive (but thread-safe).
|
||||
const auto deleteFuture = runAsync(ProjectExplorerPlugin::sharedThreadPool(), QThread::LowestPriority,
|
||||
[reader] { delete reader; });
|
||||
onFinished(deleteFuture, this, [this](const QFuture<void> &) {
|
||||
if (!--m_qmakeGlobalsRefCnt) {
|
||||
QString dir = projectFilePath().toString();
|
||||
if (!dir.endsWith(QLatin1Char('/')))
|
||||
dir += QLatin1Char('/');
|
||||
QtSupport::ProFileCacheManager::instance()->discardFiles(dir, qmakeVfs());
|
||||
QtSupport::ProFileCacheManager::instance()->decRefCount();
|
||||
m_qmakeGlobals.reset();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void QmakeBuildSystem::activeTargetWasChanged(Target *t)
|
||||
|
||||
Reference in New Issue
Block a user