Commit 36f6c02f authored by Daniel Teske's avatar Daniel Teske

Remove evaluateBuildSystem signal

It adds almost nothing and introduced some bugs.
This fixes:
Double evaluation in cmakeproject on build directory changes.
Wrong runconfiguration update in cmake for set_target_properties(target
PROPERTIES OUTPUT_NAME [..]) changes.

Unecessary runconfiguration removal in AutoTools and Generic projectmanager.

Reevaluation of .pro files on changing the active runconfiguration or deploy
configuration.

Task-number: QTCREATORBUG-7723
Task-number: QTCREATORBUG-7761

Change-Id: I50249b186917cd3a4f399f187f09ac8428ab6f9e
Reviewed-by: default avatarTobias Hunger <tobias.hunger@nokia.com>
parent 8d8ab020
......@@ -156,7 +156,7 @@ bool AutotoolsProject::fromMap(const QVariantMap &map)
this, SLOT(onFileChanged(QString)));
// Load the project tree structure.
evaluateBuildSystem();
loadProjectTree();
Profile *defaultProfile = ProfileManager::instance()->defaultProfile();
if (!activeTarget() && defaultProfile)
......@@ -165,7 +165,7 @@ bool AutotoolsProject::fromMap(const QVariantMap &map)
return true;
}
void AutotoolsProject::evaluateBuildSystem()
void AutotoolsProject::loadProjectTree()
{
if (m_makefileParserThread != 0) {
// The thread is still busy parsing a previus configuration.
......@@ -257,14 +257,12 @@ void AutotoolsProject::makefileParsingFinished()
m_makefileParserThread->deleteLater();
m_makefileParserThread = 0;
buildSystemEvaluationFinished(true);
}
void AutotoolsProject::onFileChanged(const QString &file)
{
Q_UNUSED(file);
evaluateBuildSystem();
loadProjectTree();
}
QStringList AutotoolsProject::buildTargets() const
......
......@@ -90,7 +90,7 @@ private slots:
/**
* Loads the project tree by parsing the makefiles.
*/
void evaluateBuildSystem();
void loadProjectTree();
/**
* Is invoked when the makefile parsing by m_makefileParserThread has
......
......@@ -109,8 +109,8 @@ CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName)
connect(this, SIGNAL(addedTarget(ProjectExplorer::Target*)),
SLOT(targetAdded(ProjectExplorer::Target*)));
connect(this, SIGNAL(buildDirectoryChanged()),
this, SLOT(triggerBuildSystemEvaluation()));
connect(this, SIGNAL(buildTargetsChanged()),
this, SLOT(updateRunConfigurations()));
}
CMakeProject::~CMakeProject()
......@@ -134,7 +134,7 @@ void CMakeProject::fileChanged(const QString &fileName)
{
Q_UNUSED(fileName)
evaluateBuildSystem();
parseCMakeLists();
}
void CMakeProject::changeActiveBuildConfiguration(ProjectExplorer::BuildConfiguration *bc)
......@@ -170,7 +170,7 @@ void CMakeProject::changeActiveBuildConfiguration(ProjectExplorer::BuildConfigur
copw.exec();
}
// reparse
evaluateBuildSystem();
parseCMakeLists();
}
void CMakeProject::targetAdded(ProjectExplorer::Target *t)
......@@ -185,7 +185,7 @@ void CMakeProject::targetAdded(ProjectExplorer::Target *t)
void CMakeProject::changeBuildDirectory(CMakeBuildConfiguration *bc, const QString &newBuildDirectory)
{
bc->setBuildDirectory(newBuildDirectory);
evaluateBuildSystem();
parseCMakeLists();
}
QString CMakeProject::defaultBuildDirectory() const
......@@ -193,20 +193,14 @@ QString CMakeProject::defaultBuildDirectory() const
return projectDirectory() + QLatin1String("/qtcreator-build");
}
void CMakeProject::evaluateBuildSystem()
bool CMakeProject::parseCMakeLists()
{
if (!activeTarget() ||
!activeTarget()->activeBuildConfiguration()) {
buildSystemEvaluationFinished(false);
return;
}
CMakeBuildConfiguration *activeBC = qobject_cast<CMakeBuildConfiguration *>(activeTarget()->activeBuildConfiguration());
if (!activeBC) {
buildSystemEvaluationFinished(false);
return;
return false;
}
CMakeBuildConfiguration *activeBC = static_cast<CMakeBuildConfiguration *>(activeTarget()->activeBuildConfiguration());
foreach (Core::IEditor *editor, Core::EditorManager::instance()->openedEditors())
if (isProjectFile(editor->document()->fileName()))
editor->document()->infoBar()->removeInfo(QLatin1String("CMakeEditor.RunCMake"));
......@@ -216,8 +210,7 @@ void CMakeProject::evaluateBuildSystem()
if (cbpFile.isEmpty()) {
emit buildTargetsChanged();
buildSystemEvaluationFinished(true);
return;
return false;
}
// setFolderName
......@@ -228,8 +221,7 @@ void CMakeProject::evaluateBuildSystem()
if (!cbpparser.parseCbpFile(cbpFile)) {
// TODO report error
emit buildTargetsChanged();
buildSystemEvaluationFinished(true);
return;
return false;
}
foreach (const QString &file, m_watcher->files())
......@@ -296,8 +288,9 @@ void CMakeProject::evaluateBuildSystem()
ToolChain *tc = ProjectExplorer::ToolChainProfileInformation::toolChain(activeTarget()->profile());
if (!tc) {
buildSystemEvaluationFinished(true);
return;
emit buildTargetsChanged();
emit fileListChanged();
return true;
}
QStringList allIncludePaths;
......@@ -345,7 +338,7 @@ void CMakeProject::evaluateBuildSystem()
emit buildTargetsChanged();
emit fileListChanged();
buildSystemEvaluationFinished(true);
return true;
}
bool CMakeProject::isProjectFile(const QString &fileName)
......@@ -569,7 +562,7 @@ bool CMakeProject::fromMap(const QVariantMap &map)
m_watcher = new QFileSystemWatcher(this);
connect(m_watcher, SIGNAL(fileChanged(QString)), this, SLOT(fileChanged(QString)));
triggerBuildSystemEvaluation();
parseCMakeLists();
if (hasBuildTarget("all")) {
MakeStep *makeStep = qobject_cast<MakeStep *>(
......@@ -622,6 +615,71 @@ QString CMakeProject::uiHeaderFile(const QString &uiFile)
return QDir::cleanPath(uiHeaderFilePath);
}
void CMakeProject::updateRunConfigurations()
{
foreach (Target *t, targets())
updateRunConfigurations(t);
}
// TODO Compare with updateDefaultRunConfigurations();
void CMakeProject::updateRunConfigurations(Target *t)
{
// *Update* runconfigurations:
QMultiMap<QString, CMakeRunConfiguration*> existingRunConfigurations;
QList<ProjectExplorer::RunConfiguration *> toRemove;
foreach (ProjectExplorer::RunConfiguration *rc, t->runConfigurations()) {
if (CMakeRunConfiguration* cmakeRC = qobject_cast<CMakeRunConfiguration *>(rc))
existingRunConfigurations.insert(cmakeRC->title(), cmakeRC);
QtSupport::CustomExecutableRunConfiguration *ceRC =
qobject_cast<QtSupport::CustomExecutableRunConfiguration *>(rc);
if (ceRC && !ceRC->isConfigured())
toRemove << rc;
}
foreach (const CMakeBuildTarget &ct, buildTargets()) {
if (ct.library)
continue;
if (ct.executable.isEmpty())
continue;
if (ct.title.endsWith("/fast"))
continue;
QList<CMakeRunConfiguration *> list = existingRunConfigurations.values(ct.title);
if (!list.isEmpty()) {
// Already exists, so override the settings...
foreach (CMakeRunConfiguration *rc, list) {
rc->setExecutable(ct.executable);
rc->setBaseWorkingDirectory(ct.workingDirectory);
rc->setEnabled(true);
}
existingRunConfigurations.remove(ct.title);
} else {
// Does not exist yet
Core::Id id = CMakeRunConfigurationFactory::idFromBuildTarget(ct.title);
CMakeRunConfiguration *rc = new CMakeRunConfiguration(t, id, ct.executable,
ct.workingDirectory, ct.title);
t->addRunConfiguration(rc);
}
}
QMultiMap<QString, CMakeRunConfiguration *>::const_iterator it =
existingRunConfigurations.constBegin();
for ( ; it != existingRunConfigurations.constEnd(); ++it) {
CMakeRunConfiguration *rc = it.value();
// The executables for those runconfigurations aren't build by the current buildconfiguration
// We just set a disable flag and show that in the display name
rc->setEnabled(false);
// removeRunConfiguration(rc);
}
foreach (ProjectExplorer::RunConfiguration *rc, toRemove)
t->removeRunConfiguration(rc);
if (t->runConfigurations().isEmpty()) {
// Oh no, no run configuration,
// create a custom executable run configuration
t->addRunConfiguration(new QtSupport::CustomExecutableRunConfiguration(t));
}
}
void CMakeProject::createUiCodeModelSupport()
{
// qDebug()<<"creatUiCodeModelSupport()";
......@@ -864,7 +922,7 @@ void CMakeBuildSettingsWidget::runCMake()
CMakeOpenProjectWizard::WantToUpdate,
m_buildConfiguration->environment());
if (copw.exec() == QDialog::Accepted)
project->evaluateBuildSystem();
project->parseCMakeLists();
}
/////
......
......@@ -102,6 +102,7 @@ public:
bool isProjectFile(const QString &fileName);
bool parseCMakeLists();
signals:
/// emitted after parsing
......@@ -122,9 +123,9 @@ private slots:
void editorAboutToClose(Core::IEditor *editor);
void uiEditorContentsChanged();
void buildStateChanged(ProjectExplorer::Project *project);
private:
void evaluateBuildSystem();
void updateRunConfigurations();
private:
void buildTree(CMakeProjectNode *rootNode, QList<ProjectExplorer::FileNode *> list);
void gatherFileNodes(ProjectExplorer::FolderNode *parent, QList<ProjectExplorer::FileNode *> &list);
ProjectExplorer::FolderNode *findOrCreateFolder(CMakeProjectNode *rootNode, QString directory);
......
......@@ -125,7 +125,7 @@ void CMakeManager::runCMake(ProjectExplorer::Project *project)
CMakeOpenProjectWizard::WantToUpdate,
bc->environment());
if (copw.exec() == QDialog::Accepted)
cmakeProject->triggerBuildSystemEvaluation();
cmakeProject->parseCMakeLists();
}
ProjectExplorer::Project *CMakeManager::openProject(const QString &fileName, QString *errorString)
......
......@@ -67,20 +67,6 @@ const char ARGUMENTS_KEY[] = "CMakeProjectManager.CMakeRunConfiguration.Argument
const char USER_ENVIRONMENT_CHANGES_KEY[] = "CMakeProjectManager.CMakeRunConfiguration.UserEnvironmentChanges";
const char BASE_ENVIRONMENT_BASE_KEY[] = "CMakeProjectManager.BaseEnvironmentBase";
QString buildTargetFromId(Core::Id id)
{
QString idstr = QString::fromUtf8(id.name());
if (!idstr.startsWith(QLatin1String(CMAKE_RC_PREFIX)))
return QString();
return idstr.mid(QString::fromLatin1(CMAKE_RC_PREFIX).length());
}
Core::Id idFromBuildTarget(const QString &target)
{
QString id = QString::fromLatin1(CMAKE_RC_PREFIX) + target;
return Core::Id(id.toUtf8().constData());
}
} // namespace
CMakeRunConfiguration::CMakeRunConfiguration(ProjectExplorer::Target *parent, Core::Id id, const QString &target,
......@@ -568,3 +554,17 @@ ProjectExplorer::RunConfiguration *CMakeRunConfigurationFactory::restore(Project
delete rc;
return 0;
}
QString CMakeRunConfigurationFactory::buildTargetFromId(Core::Id id)
{
QString idstr = QString::fromUtf8(id.name());
if (!idstr.startsWith(QLatin1String(CMAKE_RC_PREFIX)))
return QString();
return idstr.mid(QString::fromLatin1(CMAKE_RC_PREFIX).length());
}
Core::Id CMakeRunConfigurationFactory::idFromBuildTarget(const QString &target)
{
QString id = QString::fromLatin1(CMAKE_RC_PREFIX) + target;
return Core::Id(id.toUtf8().constData());
}
......@@ -173,6 +173,9 @@ public:
QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent) const;
QString displayNameForId(const Core::Id id) const;
static Core::Id idFromBuildTarget(const QString &target);
static QString buildTargetFromId(Core::Id id);
private:
bool canHandle(ProjectExplorer::Target *parent) const;
};
......
......@@ -448,14 +448,8 @@ bool GenericProject::fromMap(const QVariantMap &map)
setIncludePaths(allIncludePaths());
evaluateBuildSystem();
return true;
}
void GenericProject::evaluateBuildSystem()
{
refresh(Everything);
buildSystemEvaluationFinished(true);
return true;
}
////////////////////////////////////////////////////////////////////////////////////
......
......@@ -98,7 +98,6 @@ protected:
bool fromMap(const QVariantMap &map);
private:
void evaluateBuildSystem();
bool saveRawFileList(const QStringList &rawFileList);
void parseProject(RefreshOptions options);
QStringList processEntries(const QStringList &paths,
......
......@@ -102,8 +102,6 @@ signals:
void environmentChanged();
void buildDirectoryChanged();
void enabledChanged();
/// Emitted whenever the build system needs to be (re-) evaluated
void requestBuildSystemEvaluation();
protected:
BuildConfiguration(Target *target, const Core::Id id);
......
......@@ -68,7 +68,6 @@ public:
signals:
void enabledChanged();
void requestBuildSystemEvaluation();
protected:
DeployConfiguration(Target *target, const Core::Id id);
......
......@@ -162,8 +162,6 @@ void Project::addTarget(Target *t)
SLOT(changeEnvironment()));
connect(t, SIGNAL(buildConfigurationEnabledChanged()),
this, SLOT(changeBuildConfigurationEnabled()));
connect(t, SIGNAL(requestBuildSystemEvaluation()),
this, SLOT(triggerBuildSystemEvaluation()));
connect(t, SIGNAL(buildDirectoryChanged()),
this, SLOT(onBuildDirectoryChanged()));
emit addedTarget(t);
......@@ -399,9 +397,6 @@ void Project::setProjectLanguage(Core::Context language)
d->m_projectLanguage = language;
}
void Project::evaluateBuildSystem()
{ buildSystemEvaluationFinished(true); }
Core::Context Project::projectContext() const
{
return d->m_projectContext;
......@@ -435,27 +430,6 @@ void Project::configureAsExampleProject(const QStringList &platforms)
Q_UNUSED(platforms);
}
void Project::triggerBuildSystemEvaluation()
{
Target *target = qobject_cast<Target *>(sender());
if (target && target != activeTarget())
return;
evaluateBuildSystem();
}
void Project::buildSystemEvaluationFinished(bool success)
{
if (!success)
return;
// Create new run configurations:
foreach (Target *t, targets())
t->updateDefaultRunConfigurations();
emit buildSystemEvaluated();
}
void Project::onBuildDirectoryChanged()
{
Target *target = qobject_cast<Target *>(sender());
......
......@@ -124,12 +124,6 @@ public:
virtual bool needsConfiguration() const;
virtual void configureAsExampleProject(const QStringList &platforms);
public slots:
void triggerBuildSystemEvaluation();
protected slots:
void buildSystemEvaluationFinished(bool success);
signals:
void displayNameChanged();
void fileListChanged();
......@@ -143,8 +137,8 @@ signals:
void environmentChanged();
void buildConfigurationEnabledChanged();
void buildDirectoryChanged();
void buildSystemEvaluated();
void settingsLoaded();
void aboutToSaveSettings();
......@@ -155,13 +149,6 @@ protected:
virtual void setProjectContext(Core::Context context);
virtual void setProjectLanguage(Core::Context language);
// Implement this to (re-)evaluate the build system of the project.
//
// This method is triggered by one of its active children (active*Configuration
// of the activeTarget) whenever some settings that has influence on the build
// system parsing is changed.
virtual void evaluateBuildSystem();
private slots:
void changeEnvironment();
void changeBuildConfigurationEnabled();
......
......@@ -236,9 +236,6 @@ void Target::addBuildConfiguration(BuildConfiguration *configuration)
SLOT(changeEnvironment()));
connect(configuration, SIGNAL(enabledChanged()),
this, SLOT(changeBuildConfigurationEnabled()));
connect(configuration, SIGNAL(requestBuildSystemEvaluation()),
this, SLOT(onRequestBuildSystemEvaluation()));
if (!activeBuildConfiguration())
setActiveBuildConfiguration(configuration);
......@@ -290,7 +287,6 @@ void Target::setActiveBuildConfiguration(BuildConfiguration *configuration)
emit environmentChanged();
emit buildConfigurationEnabledChanged();
emit buildDirectoryChanged();
emit requestBuildSystemEvaluation();
}
}
......@@ -314,7 +310,6 @@ void Target::addDeployConfiguration(DeployConfiguration *dc)
d->m_deployConfigurations.push_back(dc);
connect(dc, SIGNAL(enabledChanged()), this, SLOT(changeDeployConfigurationEnabled()));
connect(dc, SIGNAL(requestBuildSystemEvaluation()), this, SLOT(onRequestBuildSystemEvaluation()));
emit addedDeployConfiguration(dc);
......@@ -367,7 +362,6 @@ void Target::setActiveDeployConfiguration(DeployConfiguration *dc)
d->m_activeDeployConfiguration = dc;
emit activeDeployConfigurationChanged(d->m_activeDeployConfiguration);
emit deployConfigurationEnabledChanged();
emit requestBuildSystemEvaluation();
}
updateDeviceState();
}
......@@ -450,7 +444,6 @@ void Target::setActiveRunConfiguration(RunConfiguration* configuration)
d->m_activeRunConfiguration = configuration;
emit activeRunConfigurationChanged(d->m_activeRunConfiguration);
emit runConfigurationEnabledChanged();
emit requestBuildSystemEvaluation();
}
updateDeviceState();
}
......@@ -835,14 +828,4 @@ bool Target::fromMap(const QVariantMap &map)
return true;
}
void Target::onRequestBuildSystemEvaluation()
{
ProjectConfiguration *config = qobject_cast<ProjectConfiguration *>(sender());
if (!config)
return;
if (config == static_cast<ProjectConfiguration *>(activeBuildConfiguration())
|| config == static_cast<ProjectConfiguration *>(activeDeployConfiguration()))
emit requestBuildSystemEvaluation();
}
} // namespace ProjectExplorer
......@@ -150,14 +150,12 @@ signals:
void deployConfigurationEnabledChanged();
void runConfigurationEnabledChanged();
/// Emitted whenever the project should (re-)evaluate the build system
void requestBuildSystemEvaluation();
// Remove all the signals below, they are stupid
/// Emitted whenever the current build configuartion changed or the build directory of the current
/// build configuration was changed.
void buildDirectoryChanged();
public slots:
void onRequestBuildSystemEvaluation();
void onBuildDirectoryChanged();
protected:
......
......@@ -376,7 +376,7 @@ void QMakeStep::setUserArguments(const QString &arguments)
emit userArgumentsChanged();
qt4BuildConfiguration()->emitQMakeBuildConfigurationChanged();
qt4BuildConfiguration()->emitEvaluateBuildSystem();
qt4BuildConfiguration()->emitProFileEvaluateNeeded();
}
bool QMakeStep::isQmlDebuggingLibrarySupported(QString *reason) const
......@@ -438,7 +438,7 @@ void QMakeStep::setLinkQmlDebuggingLibrary(bool enable)
emit linkQmlDebuggingLibraryChanged();
qt4BuildConfiguration()->emitQMakeBuildConfigurationChanged();
qt4BuildConfiguration()->emitEvaluateBuildSystem();
qt4BuildConfiguration()->emitProFileEvaluateNeeded();
}
QStringList QMakeStep::parserArguments()
......
......@@ -136,14 +136,14 @@ void Qt4BuildConfiguration::ctor()
connect(this, SIGNAL(environmentChanged()),
this, SLOT(emitBuildDirectoryChanged()));
connect(this, SIGNAL(environmentChanged()),
this, SLOT(emitEvaluateBuildSystem()));
this, SLOT(emitProFileEvaluateNeeded()));
connect(target(), SIGNAL(profileChanged()),
this, SLOT(profileChanged()));
}
void Qt4BuildConfiguration::profileChanged()
{
emit requestBuildSystemEvaluation();
emitProFileEvaluateNeeded();
emit environmentChanged();
emitBuildDirectoryChanged();
}
......@@ -265,7 +265,7 @@ void Qt4BuildConfiguration::setShadowBuildAndDirectory(bool shadowBuild, const Q
emit environmentChanged();
emitBuildDirectoryChanged();
emitEvaluateBuildSystem();
emitProFileEvaluateNeeded();
}
QString Qt4BuildConfiguration::defaultMakeTarget() const
......@@ -294,14 +294,17 @@ void Qt4BuildConfiguration::setQMakeBuildConfiguration(QtSupport::BaseQtVersion:
return;
m_qmakeBuildConfiguration = config;
emitEvaluateBuildSystem();
emit qmakeBuildConfigurationChanged();
emitBuildDirectoryChanged();
emitProFileEvaluateNeeded();
}
void Qt4BuildConfiguration::emitEvaluateBuildSystem()
void Qt4BuildConfiguration::emitProFileEvaluateNeeded()
{
emit requestBuildSystemEvaluation();
Target *t = target();
Project *p = t->project();
if (t->activeBuildConfiguration() == this && p->activeTarget() == t)
static_cast<Qt4Project *>(p)->scheduleAsyncUpdate();
}
void Qt4BuildConfiguration::emitQMakeBuildConfigurationChanged()
......
......@@ -121,7 +121,7 @@ public:
bool supportsShadowBuilds();
public slots:
void emitEvaluateBuildSystem();
void emitProFileEvaluateNeeded();
signals:
/// emitted for setQMakeBuildConfig, not emitted for Qt version changes, even
......
......@@ -342,6 +342,7 @@ bool Qt4ProjectFile::reload(QString *errorString, ReloadFlag flag, ChangeType ty
}
} // namespace Internal
/*!
\class Qt4Project
......@@ -360,7 +361,8 @@ Qt4Project::Qt4Project(Qt4Manager *manager, const QString& fileName) :
m_asyncUpdateState(NoState),
m_cancelEvaluate(false),
m_codeModelCanceled(false),
m_centralizedFolderWatcher(0)
m_centralizedFolderWatcher(0),
m_activeTarget(0)