forked from qt-creator/qt-creator
ProjectExplorer: Handle parsingStarted/Finished in BuildConfiguration
Make all buildconfigurations disabled while the project parses. This unifies how this is handled in different build systems. Change-Id: I6afca3743ad1433529a4f9d3bfdf73042799e456 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -89,7 +89,6 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(Target *parent, Core::Id id)
|
||||
target()->kit(),
|
||||
displayName(),
|
||||
BuildConfiguration::Unknown));
|
||||
connect(project(), &Project::parsingFinished, this, &BuildConfiguration::enabledChanged);
|
||||
|
||||
BuildSystem *bs = qobject_cast<CMakeBuildSystem *>(project()->buildSystem());
|
||||
|
||||
@@ -223,11 +222,6 @@ void CMakeBuildConfiguration::initialize(const BuildInfo &info)
|
||||
setConfigurationForCMake(extraInfo.configuration);
|
||||
}
|
||||
|
||||
bool CMakeBuildConfiguration::isEnabled() const
|
||||
{
|
||||
return m_error.isEmpty() && !isParsing();
|
||||
}
|
||||
|
||||
QString CMakeBuildConfiguration::disabledReason() const
|
||||
{
|
||||
return error();
|
||||
@@ -257,11 +251,6 @@ bool CMakeBuildConfiguration::fromMap(const QVariantMap &map)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CMakeBuildConfiguration::isParsing() const
|
||||
{
|
||||
return project()->isParsing() && isActive();
|
||||
}
|
||||
|
||||
const QList<BuildTargetInfo> CMakeBuildConfiguration::appTargets() const
|
||||
{
|
||||
QList<BuildTargetInfo> appTargetList;
|
||||
|
@@ -55,8 +55,6 @@ class CMakeBuildConfiguration : public ProjectExplorer::BuildConfiguration
|
||||
public:
|
||||
void emitBuildTypeChanged();
|
||||
|
||||
bool isEnabled() const override;
|
||||
|
||||
CMakeConfig configurationForCMake() const;
|
||||
CMakeConfig configurationFromCMake() const;
|
||||
|
||||
@@ -93,8 +91,6 @@ private:
|
||||
|
||||
bool fromMap(const QVariantMap &map) override;
|
||||
|
||||
bool isParsing() const;
|
||||
|
||||
enum ForceEnabledChanged { False, True };
|
||||
void clearError(ForceEnabledChanged fec = ForceEnabledChanged::False);
|
||||
|
||||
|
@@ -252,7 +252,7 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc)
|
||||
m_showProgressTimer.start();
|
||||
});
|
||||
|
||||
if (m_buildConfiguration->isParsing())
|
||||
if (project->isParsing())
|
||||
m_showProgressTimer.start();
|
||||
else {
|
||||
m_configModel->setConfiguration(m_buildConfiguration->configurationFromCMake());
|
||||
@@ -363,7 +363,7 @@ void CMakeBuildSettingsWidget::setWarning(const QString &message)
|
||||
|
||||
void CMakeBuildSettingsWidget::updateButtonState()
|
||||
{
|
||||
const bool isParsing = m_buildConfiguration->isParsing();
|
||||
const bool isParsing = m_buildConfiguration->project()->isParsing();
|
||||
const bool hasChanges = m_configModel->hasChanges();
|
||||
m_resetButton->setEnabled(hasChanges && !isParsing);
|
||||
m_reconfigureButton->setEnabled((hasChanges || m_configModel->hasCMakeChanges()) && !isParsing);
|
||||
|
@@ -106,6 +106,9 @@ BuildConfiguration::BuildConfiguration(Target *target, Core::Id id)
|
||||
this->target()->buildEnvironmentChanged(this);
|
||||
});
|
||||
|
||||
connect(project(), &Project::parsingStarted, this, &BuildConfiguration::enabledChanged);
|
||||
connect(project(), &Project::parsingFinished, this, &BuildConfiguration::enabledChanged);
|
||||
|
||||
connect(this, &BuildConfiguration::enabledChanged, this, [this] {
|
||||
if (isActive() && project() == SessionManager::startupProject()) {
|
||||
ProjectExplorerPlugin::updateActions();
|
||||
@@ -336,11 +339,15 @@ void BuildConfiguration::setUserEnvironmentChanges(const Utils::EnvironmentItems
|
||||
|
||||
bool BuildConfiguration::isEnabled() const
|
||||
{
|
||||
return true;
|
||||
return !project()->isParsing() && project()->hasParsingData();
|
||||
}
|
||||
|
||||
QString BuildConfiguration::disabledReason() const
|
||||
{
|
||||
if (project()->isParsing())
|
||||
return (tr("The project is currently being parsed."));
|
||||
if (!project()->hasParsingData())
|
||||
return (tr("The project was not parsed successfully."));
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
@@ -86,9 +86,6 @@ QbsBuildConfiguration::QbsBuildConfiguration(Target *target, Core::Id id)
|
||||
connect(m_configurationName, &BaseStringAspect::changed,
|
||||
this, &BuildConfiguration::buildDirectoryChanged);
|
||||
|
||||
connect(project(), &Project::parsingStarted, this, &BuildConfiguration::enabledChanged);
|
||||
connect(project(), &Project::parsingFinished, this, &BuildConfiguration::enabledChanged);
|
||||
|
||||
connect(this, &BuildConfiguration::environmentChanged,
|
||||
this, &QbsBuildConfiguration::triggerReparseIfActive);
|
||||
connect(this, &BuildConfiguration::buildDirectoryChanged,
|
||||
@@ -176,20 +173,6 @@ Internal::QbsProject *QbsBuildConfiguration::qbsProject() const
|
||||
return qobject_cast<Internal::QbsProject *>(project());
|
||||
}
|
||||
|
||||
bool QbsBuildConfiguration::isEnabled() const
|
||||
{
|
||||
return !project()->isParsing() && qbsProject()->hasParseResult();
|
||||
}
|
||||
|
||||
QString QbsBuildConfiguration::disabledReason() const
|
||||
{
|
||||
if (project()->isParsing())
|
||||
return tr("Parsing the Qbs project.");
|
||||
if (!qbsProject()->hasParseResult())
|
||||
return tr("Parsing of Qbs project has failed.");
|
||||
return QString();
|
||||
}
|
||||
|
||||
BuildConfiguration::BuildType QbsBuildConfiguration::buildType() const
|
||||
{
|
||||
QString variant;
|
||||
|
@@ -55,9 +55,6 @@ public:
|
||||
|
||||
Internal::QbsProject *qbsProject() const;
|
||||
|
||||
bool isEnabled() const override;
|
||||
QString disabledReason() const override;
|
||||
|
||||
BuildType buildType() const override;
|
||||
|
||||
void setChangedFiles(const QStringList &files);
|
||||
|
@@ -410,11 +410,6 @@ QString QbsProject::profileForTarget(const Target *t) const
|
||||
return QbsManager::profileForKit(t->kit());
|
||||
}
|
||||
|
||||
bool QbsProject::hasParseResult() const
|
||||
{
|
||||
return qbsProject().isValid();
|
||||
}
|
||||
|
||||
qbs::Project QbsProject::qbsProject() const
|
||||
{
|
||||
return m_qbsProject;
|
||||
|
@@ -82,7 +82,6 @@ public:
|
||||
static ProjectExplorer::FileType fileTypeFor(const QSet<QString> &tags);
|
||||
|
||||
QString profileForTarget(const ProjectExplorer::Target *t) const;
|
||||
bool hasParseResult() const;
|
||||
void parseCurrentBuildConfiguration();
|
||||
void scheduleParsing() { m_parsingScheduled = true; }
|
||||
bool parsingScheduled() const { return m_parsingScheduled; }
|
||||
|
@@ -542,26 +542,6 @@ QString QmakeBuildConfiguration::extractSpecFromArguments(QString *args,
|
||||
return parsedSpec.toString();
|
||||
}
|
||||
|
||||
bool QmakeBuildConfiguration::isEnabled() const
|
||||
{
|
||||
return m_isEnabled;
|
||||
}
|
||||
|
||||
QString QmakeBuildConfiguration::disabledReason() const
|
||||
{
|
||||
if (!m_isEnabled)
|
||||
return tr("Parsing the .pro file");
|
||||
return QString();
|
||||
}
|
||||
|
||||
void QmakeBuildConfiguration::setEnabled(bool enabled)
|
||||
{
|
||||
if (m_isEnabled == enabled)
|
||||
return;
|
||||
m_isEnabled = enabled;
|
||||
emit enabledChanged();
|
||||
}
|
||||
|
||||
/*!
|
||||
\class QmakeBuildConfigurationFactory
|
||||
*/
|
||||
|
@@ -82,11 +82,6 @@ public:
|
||||
|
||||
QVariantMap toMap() const override;
|
||||
|
||||
bool isEnabled() const override;
|
||||
QString disabledReason() const override;
|
||||
/// \internal For QmakeProject, since that manages the parsing information
|
||||
void setEnabled(bool enabled);
|
||||
|
||||
BuildType buildType() const override;
|
||||
|
||||
void addToEnvironment(Utils::Environment &env) const override;
|
||||
@@ -129,7 +124,6 @@ private:
|
||||
LastKitState m_lastKitState;
|
||||
|
||||
bool m_shadowBuild = true;
|
||||
bool m_isEnabled = true;
|
||||
QtSupport::BaseQtVersion::QmakeBuildConfigs m_qmakeBuildConfiguration;
|
||||
QmakeProFileNode *m_subNodeBuild = nullptr;
|
||||
ProjectExplorer::FileNode *m_fileNodeBuild = nullptr;
|
||||
|
@@ -362,7 +362,6 @@ void QmakeProject::scheduleAsyncUpdate(QmakeProFile *file, QmakeProFile::AsyncUp
|
||||
}
|
||||
|
||||
file->setParseInProgressRecursive(true);
|
||||
setAllBuildConfigurationsEnabled(false);
|
||||
|
||||
if (m_asyncUpdateState == AsyncFullUpdatePending) {
|
||||
// Just postpone
|
||||
@@ -418,7 +417,6 @@ void QmakeProject::scheduleAsyncUpdate(QmakeProFile::AsyncUpdateDelay delay)
|
||||
}
|
||||
|
||||
rootProFile()->setParseInProgressRecursive(true);
|
||||
setAllBuildConfigurationsEnabled(false);
|
||||
|
||||
if (m_asyncUpdateState == AsyncUpdateInProgress) {
|
||||
m_cancelEvaluate = true;
|
||||
@@ -476,11 +474,9 @@ void QmakeProject::decrementPendingEvaluateFutures()
|
||||
if (m_asyncUpdateState == AsyncFullUpdatePending || m_asyncUpdateState == AsyncPartialUpdatePending) {
|
||||
// Already parsing!
|
||||
rootProFile()->setParseInProgressRecursive(true);
|
||||
setAllBuildConfigurationsEnabled(false);
|
||||
startAsyncTimer(QmakeProFile::ParseLater);
|
||||
} else if (m_asyncUpdateState != ShuttingDown){
|
||||
// After being done, we need to call:
|
||||
setAllBuildConfigurationsEnabled(true);
|
||||
|
||||
m_asyncUpdateState = Base;
|
||||
updateCodeModels();
|
||||
@@ -731,17 +727,6 @@ void QmakeProject::activeTargetWasChanged()
|
||||
scheduleAsyncUpdate();
|
||||
}
|
||||
|
||||
void QmakeProject::setAllBuildConfigurationsEnabled(bool enabled)
|
||||
{
|
||||
foreach (Target *t, targets()) {
|
||||
foreach (BuildConfiguration *bc, t->buildConfigurations()) {
|
||||
auto qmakeBc = qobject_cast<QmakeBuildConfiguration *>(bc);
|
||||
if (qmakeBc)
|
||||
qmakeBc->setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void notifyChangedHelper(const FilePath &fileName, QmakeProFile *file)
|
||||
{
|
||||
if (file->filePath() == fileName) {
|
||||
|
@@ -127,8 +127,6 @@ private:
|
||||
void buildFinished(bool success);
|
||||
void activeTargetWasChanged();
|
||||
|
||||
void setAllBuildConfigurationsEnabled(bool enabled);
|
||||
|
||||
QString executableFor(const QmakeProFile *file);
|
||||
|
||||
void updateCppCodeModel();
|
||||
|
Reference in New Issue
Block a user