Commit f6d5ba9b authored by Daniel Teske's avatar Daniel Teske

CMake: Reparse .cbp files on swtiching targets

Also fix the code to not reparse the wrong file if the bc for a non
active target would be changed.

Task-number: QTCREATORBUG-8063
Change-Id: I40be4bbb1a5ef6ccc78515f153534a7304cae0e1
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 09faf55f
......@@ -98,6 +98,7 @@ static inline QString formWindowEditorContents(const QObject *editor)
*/
CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName)
: m_manager(manager),
m_activeTarget(0),
m_fileName(fileName),
m_rootNode(new CMakeProjectNode(m_fileName)),
m_lastEditor(0)
......@@ -107,8 +108,6 @@ CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName)
m_file = new CMakeFile(this, fileName);
connect(this, SIGNAL(addedTarget(ProjectExplorer::Target*)),
SLOT(targetAdded(ProjectExplorer::Target*)));
connect(this, SIGNAL(buildTargetsChanged()),
this, SLOT(updateRunConfigurations()));
}
......@@ -139,7 +138,7 @@ void CMakeProject::fileChanged(const QString &fileName)
void CMakeProject::changeActiveBuildConfiguration(ProjectExplorer::BuildConfiguration *bc)
{
if (!bc || bc->target() != activeTarget())
if (!bc)
return;
CMakeBuildConfiguration *cmakebc = static_cast<CMakeBuildConfiguration *>(bc);
......@@ -170,13 +169,22 @@ void CMakeProject::changeActiveBuildConfiguration(ProjectExplorer::BuildConfigur
parseCMakeLists();
}
void CMakeProject::targetAdded(ProjectExplorer::Target *t)
void CMakeProject::activeTargetWasChanged(Target *target)
{
if (!t)
if (m_activeTarget) {
disconnect(m_activeTarget, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)),
this, SLOT(changeActiveBuildConfiguration(ProjectExplorer::BuildConfiguration*)));
}
m_activeTarget = target;
if (!m_activeTarget)
return;
connect(t, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)),
SLOT(changeActiveBuildConfiguration(ProjectExplorer::BuildConfiguration*)));
connect(m_activeTarget, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)),
this, SLOT(changeActiveBuildConfiguration(ProjectExplorer::BuildConfiguration*)));
changeActiveBuildConfiguration(m_activeTarget->activeBuildConfiguration());
}
void CMakeProject::changeBuildDirectory(CMakeBuildConfiguration *bc, const QString &newBuildDirectory)
......@@ -604,6 +612,14 @@ bool CMakeProject::fromMap(const QVariantMap &map)
connect(ProjectExplorer::ProjectExplorerPlugin::instance()->buildManager(), SIGNAL(buildStateChanged(ProjectExplorer::Project*)),
this, SLOT(buildStateChanged(ProjectExplorer::Project*)));
m_activeTarget = activeTarget();
if (m_activeTarget)
connect(m_activeTarget, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)),
this, SLOT(changeActiveBuildConfiguration(ProjectExplorer::BuildConfiguration*)));
connect(this, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)),
this, SLOT(activeTargetWasChanged(ProjectExplorer::Target*)));
return true;
}
......
......@@ -51,6 +51,8 @@ QT_BEGIN_NAMESPACE
class QFileSystemWatcher;
QT_END_NAMESPACE
namespace ProjectExplorer { class Target; }
namespace CMakeProjectManager {
namespace Internal {
......@@ -116,8 +118,8 @@ protected:
private slots:
void fileChanged(const QString &fileName);
void activeTargetWasChanged(ProjectExplorer::Target *target);
void changeActiveBuildConfiguration(ProjectExplorer::BuildConfiguration*);
void targetAdded(ProjectExplorer::Target *);
void editorChanged(Core::IEditor *editor);
void editorAboutToClose(Core::IEditor *editor);
......@@ -135,6 +137,7 @@ private:
void updateRunConfigurations(ProjectExplorer::Target *t);
CMakeManager *m_manager;
ProjectExplorer::Target *m_activeTarget;
QString m_fileName;
CMakeFile *m_file;
QString m_projectName;
......
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