forked from qt-creator/qt-creator
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: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -98,6 +98,7 @@ static inline QString formWindowEditorContents(const QObject *editor)
|
|||||||
*/
|
*/
|
||||||
CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName)
|
CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName)
|
||||||
: m_manager(manager),
|
: m_manager(manager),
|
||||||
|
m_activeTarget(0),
|
||||||
m_fileName(fileName),
|
m_fileName(fileName),
|
||||||
m_rootNode(new CMakeProjectNode(m_fileName)),
|
m_rootNode(new CMakeProjectNode(m_fileName)),
|
||||||
m_lastEditor(0)
|
m_lastEditor(0)
|
||||||
@@ -107,8 +108,6 @@ CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName)
|
|||||||
|
|
||||||
m_file = new CMakeFile(this, fileName);
|
m_file = new CMakeFile(this, fileName);
|
||||||
|
|
||||||
connect(this, SIGNAL(addedTarget(ProjectExplorer::Target*)),
|
|
||||||
SLOT(targetAdded(ProjectExplorer::Target*)));
|
|
||||||
connect(this, SIGNAL(buildTargetsChanged()),
|
connect(this, SIGNAL(buildTargetsChanged()),
|
||||||
this, SLOT(updateRunConfigurations()));
|
this, SLOT(updateRunConfigurations()));
|
||||||
}
|
}
|
||||||
@@ -139,7 +138,7 @@ void CMakeProject::fileChanged(const QString &fileName)
|
|||||||
|
|
||||||
void CMakeProject::changeActiveBuildConfiguration(ProjectExplorer::BuildConfiguration *bc)
|
void CMakeProject::changeActiveBuildConfiguration(ProjectExplorer::BuildConfiguration *bc)
|
||||||
{
|
{
|
||||||
if (!bc || bc->target() != activeTarget())
|
if (!bc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CMakeBuildConfiguration *cmakebc = static_cast<CMakeBuildConfiguration *>(bc);
|
CMakeBuildConfiguration *cmakebc = static_cast<CMakeBuildConfiguration *>(bc);
|
||||||
@@ -170,13 +169,22 @@ void CMakeProject::changeActiveBuildConfiguration(ProjectExplorer::BuildConfigur
|
|||||||
parseCMakeLists();
|
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;
|
return;
|
||||||
|
|
||||||
connect(t, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)),
|
connect(m_activeTarget, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)),
|
||||||
SLOT(changeActiveBuildConfiguration(ProjectExplorer::BuildConfiguration*)));
|
this, SLOT(changeActiveBuildConfiguration(ProjectExplorer::BuildConfiguration*)));
|
||||||
|
|
||||||
|
changeActiveBuildConfiguration(m_activeTarget->activeBuildConfiguration());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMakeProject::changeBuildDirectory(CMakeBuildConfiguration *bc, const QString &newBuildDirectory)
|
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*)),
|
connect(ProjectExplorer::ProjectExplorerPlugin::instance()->buildManager(), SIGNAL(buildStateChanged(ProjectExplorer::Project*)),
|
||||||
this, SLOT(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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -51,6 +51,8 @@ QT_BEGIN_NAMESPACE
|
|||||||
class QFileSystemWatcher;
|
class QFileSystemWatcher;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace ProjectExplorer { class Target; }
|
||||||
|
|
||||||
namespace CMakeProjectManager {
|
namespace CMakeProjectManager {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -116,8 +118,8 @@ protected:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void fileChanged(const QString &fileName);
|
void fileChanged(const QString &fileName);
|
||||||
|
void activeTargetWasChanged(ProjectExplorer::Target *target);
|
||||||
void changeActiveBuildConfiguration(ProjectExplorer::BuildConfiguration*);
|
void changeActiveBuildConfiguration(ProjectExplorer::BuildConfiguration*);
|
||||||
void targetAdded(ProjectExplorer::Target *);
|
|
||||||
|
|
||||||
void editorChanged(Core::IEditor *editor);
|
void editorChanged(Core::IEditor *editor);
|
||||||
void editorAboutToClose(Core::IEditor *editor);
|
void editorAboutToClose(Core::IEditor *editor);
|
||||||
@@ -135,6 +137,7 @@ private:
|
|||||||
void updateRunConfigurations(ProjectExplorer::Target *t);
|
void updateRunConfigurations(ProjectExplorer::Target *t);
|
||||||
|
|
||||||
CMakeManager *m_manager;
|
CMakeManager *m_manager;
|
||||||
|
ProjectExplorer::Target *m_activeTarget;
|
||||||
QString m_fileName;
|
QString m_fileName;
|
||||||
CMakeFile *m_file;
|
CMakeFile *m_file;
|
||||||
QString m_projectName;
|
QString m_projectName;
|
||||||
|
Reference in New Issue
Block a user