forked from qt-creator/qt-creator
QbsProjectManager: Cache run environment
Setting up the qbs run environment is not free, and the respective code gets triggered from other plugins much more often than expected. Task-number: QTCREATORBUG-20175 Change-Id: I6529718d20738140963486caef103d6d17958d50 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -452,6 +452,7 @@ void QbsProject::updateAfterParse()
|
||||
updateCppCodeModel();
|
||||
updateQmlJsCodeModel();
|
||||
emit fileListChanged();
|
||||
emit dataChanged();
|
||||
}
|
||||
|
||||
void QbsProject::delayedUpdateAfterParse()
|
||||
@@ -609,6 +610,7 @@ void QbsProject::updateAfterBuild()
|
||||
m_extraCompilersPending = false;
|
||||
updateCppCodeModel();
|
||||
}
|
||||
emit dataChanged();
|
||||
}
|
||||
|
||||
void QbsProject::registerQbsProjectParser(QbsProjectParser *p)
|
||||
|
@@ -107,6 +107,9 @@ public:
|
||||
|
||||
void delayParsing();
|
||||
|
||||
signals:
|
||||
void dataChanged();
|
||||
|
||||
private:
|
||||
void handleQbsParsingDone(bool success);
|
||||
|
||||
|
@@ -109,6 +109,7 @@ QbsRunConfiguration::QbsRunConfiguration(Target *target)
|
||||
if (success && !terminalAspect->isUserSet())
|
||||
terminalAspect->setUseTerminal(isConsoleApplication());
|
||||
});
|
||||
connect(project, &QbsProject::dataChanged, this, [this] { m_envCache.clear(); });
|
||||
connect(BuildManager::instance(), &BuildManager::buildStateChanged, this,
|
||||
[this, project](Project *p) {
|
||||
if (p == project && !BuildManager::isBuilding(p)) {
|
||||
@@ -255,6 +256,12 @@ QString QbsRunConfiguration::baseWorkingDirectory() const
|
||||
|
||||
void QbsRunConfiguration::addToBaseEnvironment(Utils::Environment &env) const
|
||||
{
|
||||
const auto key = qMakePair(env.toStringList(), m_usingLibraryPaths);
|
||||
const auto it = m_envCache.constFind(key);
|
||||
if (it != m_envCache.constEnd()) {
|
||||
env = it.value();
|
||||
return;
|
||||
}
|
||||
QbsProject *project = static_cast<QbsProject *>(target()->project());
|
||||
if (project && project->qbsProject().isValid()) {
|
||||
const qbs::ProductData product = findProduct(project->qbsProjectData(), uniqueProductName());
|
||||
@@ -279,6 +286,7 @@ void QbsRunConfiguration::addToBaseEnvironment(Utils::Environment &env) const
|
||||
}
|
||||
}
|
||||
}
|
||||
m_envCache.insert(key, env);
|
||||
}
|
||||
|
||||
QString QbsRunConfiguration::buildSystemTarget() const
|
||||
|
@@ -28,7 +28,9 @@
|
||||
#include <projectexplorer/runnables.h>
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QHash>
|
||||
#include <QLabel>
|
||||
#include <QPair>
|
||||
#include <QStringList>
|
||||
#include <QWidget>
|
||||
|
||||
@@ -83,6 +85,9 @@ private:
|
||||
|
||||
void updateTarget();
|
||||
|
||||
using EnvCache = QHash<QPair<QStringList, bool>, Utils::Environment>;
|
||||
mutable EnvCache m_envCache;
|
||||
|
||||
QbsInstallStep *m_currentInstallStep = nullptr; // We do not take ownership!
|
||||
ProjectExplorer::BuildStepList *m_currentBuildStepList = nullptr; // We do not take ownership!
|
||||
QString m_uniqueProductName;
|
||||
|
Reference in New Issue
Block a user