Commit 46f39f56 authored by Tobias Hunger's avatar Tobias Hunger

CMake: Simplify signaling

Change-Id: I50fdaed0d813b5004c1756e9c5a6efd3ce7a3318
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent 09b127f9
......@@ -146,7 +146,6 @@ void CMakeBuildConfiguration::ctor()
this, [this, project]() {
clearError();
project->updateProjectData(this);
emit dataAvailable();
});
connect(m_buildDirManager.get(), &BuildDirManager::errorOccured,
this, [this, project](const QString &msg) {
......@@ -155,9 +154,8 @@ void CMakeBuildConfiguration::ctor()
});
connect(m_buildDirManager.get(), &BuildDirManager::configurationStarted,
this, [this, project]() {
project->handleParsingStarted();
project->handleParsingStarted(this);
clearError(ForceEnabledChanged::True);
emit parsingStarted();
});
connect(this, &CMakeBuildConfiguration::environmentChanged,
......@@ -411,7 +409,7 @@ CMakeConfig CMakeBuildConfiguration::cmakeConfiguration() const
void CMakeBuildConfiguration::setError(const QString &message)
{
QString oldMessage = m_error;
const QString oldMessage = m_error;
if (m_error != message)
m_error = message;
if (oldMessage.isEmpty() && !message.isEmpty())
......
......@@ -100,9 +100,6 @@ signals:
void errorOccured(const QString &message);
void warningOccured(const QString &message);
void parsingStarted();
void dataAvailable();
protected:
CMakeBuildConfiguration(ProjectExplorer::Target *parent, CMakeBuildConfiguration *source);
bool fromMap(const QVariantMap &map) override;
......
......@@ -214,7 +214,7 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc)
else
m_configModel->setConfiguration(m_buildConfiguration->completeCMakeConfiguration());
connect(m_buildConfiguration, &CMakeBuildConfiguration::dataAvailable,
connect(m_buildConfiguration->target()->project(), &ProjectExplorer::Project::parsingFinished,
this, [this, buildDirChooser, stretcher]() {
updateButtonState();
m_configModel->setConfiguration(m_buildConfiguration->completeCMakeConfiguration());
......
......@@ -119,7 +119,8 @@ void CMakeBuildStep::ctor(BuildStepList *bsl)
}
connect(target(), &Target::kitChanged, this, &CMakeBuildStep::cmakeCommandChanged);
connect(bc, &CMakeBuildConfiguration::dataAvailable, this, &CMakeBuildStep::handleBuildTargetChanges);
connect(project(), &Project::parsingFinished,
this, &CMakeBuildStep::handleBuildTargetChanges);
}
CMakeBuildConfiguration *CMakeBuildStep::cmakeBuildConfiguration() const
......@@ -279,10 +280,8 @@ void CMakeBuildStep::run(QFutureInterface<bool> &fi)
}
if (mustDelay) {
m_runTrigger = connect(bc, &CMakeBuildConfiguration::dataAvailable,
this, [this, &fi]() { runImpl(fi); });
m_errorTrigger = connect(bc, &CMakeBuildConfiguration::errorOccured,
this, [this, &fi](const QString& em) { handleCMakeError(fi, em); });
m_runTrigger = connect(project(), &Project::parsingFinished,
this, [this, &fi](bool success) { handleProjectWasParsed(fi, success); });
} else {
runImpl(fi);
}
......@@ -291,21 +290,18 @@ void CMakeBuildStep::run(QFutureInterface<bool> &fi)
void CMakeBuildStep::runImpl(QFutureInterface<bool> &fi)
{
// Do the actual build:
disconnectTriggers();
AbstractProcessStep::run(fi);
}
void CMakeBuildStep::handleCMakeError(QFutureInterface<bool> &fi, const QString& errorMessage)
{
disconnectTriggers();
AbstractProcessStep::stdError(tr("Error parsing CMake: %1\n").arg(errorMessage));
reportRunResult(fi, false);
}
void CMakeBuildStep::disconnectTriggers()
void CMakeBuildStep::handleProjectWasParsed(QFutureInterface<bool> &fi, bool success)
{
disconnect(m_runTrigger);
disconnect(m_errorTrigger);
if (success) {
runImpl(fi);
} else {
AbstractProcessStep::stdError(tr("Project did not parse successfully, can not build."));
reportRunResult(fi, false);
}
}
BuildStepConfigWidget *CMakeBuildStep::createConfigWidget()
......
......@@ -104,14 +104,12 @@ private:
void ctor(ProjectExplorer::BuildStepList *bsl);
void runImpl(QFutureInterface<bool> &fi);
void handleCMakeError(QFutureInterface<bool> &fi, const QString& errorMessage);
void disconnectTriggers();
void handleProjectWasParsed(QFutureInterface<bool> &fi, bool success);
void handleBuildTargetChanges();
CMakeRunConfiguration *targetsActiveRunConfiguration() const;
QMetaObject::Connection m_runTrigger;
QMetaObject::Connection m_errorTrigger;
QRegExp m_percentProgress;
QRegExp m_ninjaProgress;
......
......@@ -377,9 +377,9 @@ void CMakeProject::handleActiveBuildConfigurationChanged()
}
}
void CMakeProject::handleParsingStarted()
void CMakeProject::handleParsingStarted(const CMakeBuildConfiguration *bc)
{
if (activeTarget() && activeTarget()->activeBuildConfiguration() == sender())
if (activeTarget() && activeTarget()->activeBuildConfiguration() == bc)
emitParsingStarted();
}
......
......@@ -114,7 +114,7 @@ private:
void handleActiveTargetChanged();
void handleActiveBuildConfigurationChanged();
void handleParsingStarted();
void handleParsingStarted(const Internal::CMakeBuildConfiguration *bc);
void handleTreeScanningFinished();
void updateProjectData(Internal::CMakeBuildConfiguration *cmakeBc);
void handleParsingError(Internal::CMakeBuildConfiguration *bc);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment