forked from qt-creator/qt-creator
CMake: Simplify reparsing code
This still fixes the parsing issue when switching build configurations, but the code is simpler. Change-Id: I5748788224c5b49399550c33bcef592f193cfa8a Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
This commit is contained in:
@@ -148,8 +148,6 @@ void CMakeBuildConfiguration::ctor()
|
|||||||
m_buildDirManager, &BuildDirManager::forceReparse);
|
m_buildDirManager, &BuildDirManager::forceReparse);
|
||||||
connect(this, &CMakeBuildConfiguration::buildDirectoryChanged,
|
connect(this, &CMakeBuildConfiguration::buildDirectoryChanged,
|
||||||
m_buildDirManager, &BuildDirManager::forceReparse);
|
m_buildDirManager, &BuildDirManager::forceReparse);
|
||||||
connect(target(), &Target::kitChanged, this, &CMakeBuildConfiguration::maybeForceReparse);
|
|
||||||
connect(project, &Project::activeTargetChanged, this, &CMakeBuildConfiguration::maybeForceReparse);
|
|
||||||
|
|
||||||
connect(this, &CMakeBuildConfiguration::parsingStarted, project, &CMakeProject::handleParsingStarted);
|
connect(this, &CMakeBuildConfiguration::parsingStarted, project, &CMakeProject::handleParsingStarted);
|
||||||
connect(this, &CMakeBuildConfiguration::dataAvailable, project, &CMakeProject::parseCMakeOutput);
|
connect(this, &CMakeBuildConfiguration::dataAvailable, project, &CMakeProject::parseCMakeOutput);
|
||||||
@@ -174,11 +172,6 @@ bool CMakeBuildConfiguration::isParsing() const
|
|||||||
return m_buildDirManager && m_buildDirManager->isParsing();
|
return m_buildDirManager && m_buildDirManager->isParsing();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMakeBuildConfiguration::parse()
|
|
||||||
{
|
|
||||||
m_buildDirManager->parse();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMakeBuildConfiguration::resetData()
|
void CMakeBuildConfiguration::resetData()
|
||||||
{
|
{
|
||||||
m_buildDirManager->resetData();
|
m_buildDirManager->resetData();
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public:
|
|||||||
|
|
||||||
bool isParsing() const;
|
bool isParsing() const;
|
||||||
|
|
||||||
void parse();
|
void maybeForceReparse();
|
||||||
void resetData();
|
void resetData();
|
||||||
bool persistCMakeState();
|
bool persistCMakeState();
|
||||||
|
|
||||||
@@ -93,7 +93,6 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void ctor();
|
void ctor();
|
||||||
void maybeForceReparse();
|
|
||||||
QList<ConfigModel::DataItem> completeCMakeConfiguration() const;
|
QList<ConfigModel::DataItem> completeCMakeConfiguration() const;
|
||||||
void setCurrentCMakeConfiguration(const QList<ConfigModel::DataItem> &items);
|
void setCurrentCMakeConfiguration(const QList<ConfigModel::DataItem> &items);
|
||||||
|
|
||||||
|
|||||||
@@ -92,6 +92,8 @@ CMakeProject::CMakeProject(CMakeManager *manager, const FileName &fileName)
|
|||||||
setProjectLanguages(Core::Context(ProjectExplorer::Constants::LANG_CXX));
|
setProjectLanguages(Core::Context(ProjectExplorer::Constants::LANG_CXX));
|
||||||
|
|
||||||
rootProjectNode()->setDisplayName(fileName.parentDir().fileName());
|
rootProjectNode()->setDisplayName(fileName.parentDir().fileName());
|
||||||
|
|
||||||
|
connect(this, &CMakeProject::activeTargetChanged, this, &CMakeProject::handleActiveTargetChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMakeProject::~CMakeProject()
|
CMakeProject::~CMakeProject()
|
||||||
@@ -439,10 +441,6 @@ Project::RestoreResult CMakeProject::fromMap(const QVariantMap &map, QString *er
|
|||||||
RestoreResult result = Project::fromMap(map, errorMessage);
|
RestoreResult result = Project::fromMap(map, errorMessage);
|
||||||
if (result != RestoreResult::Ok)
|
if (result != RestoreResult::Ok)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
handleActiveTargetChanged();
|
|
||||||
handleActiveBuildConfigurationChanged();
|
|
||||||
|
|
||||||
return RestoreResult::Ok;
|
return RestoreResult::Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -461,7 +459,8 @@ void CMakeProject::handleActiveTargetChanged()
|
|||||||
if (m_connectedTarget) {
|
if (m_connectedTarget) {
|
||||||
disconnect(m_connectedTarget, &Target::activeBuildConfigurationChanged,
|
disconnect(m_connectedTarget, &Target::activeBuildConfigurationChanged,
|
||||||
this, &CMakeProject::handleActiveBuildConfigurationChanged);
|
this, &CMakeProject::handleActiveBuildConfigurationChanged);
|
||||||
|
disconnect(m_connectedTarget, &Target::kitChanged,
|
||||||
|
this, &CMakeProject::handleActiveBuildConfigurationChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_connectedTarget = activeTarget();
|
m_connectedTarget = activeTarget();
|
||||||
@@ -469,7 +468,11 @@ void CMakeProject::handleActiveTargetChanged()
|
|||||||
if (m_connectedTarget) {
|
if (m_connectedTarget) {
|
||||||
connect(m_connectedTarget, &Target::activeBuildConfigurationChanged,
|
connect(m_connectedTarget, &Target::activeBuildConfigurationChanged,
|
||||||
this, &CMakeProject::handleActiveBuildConfigurationChanged);
|
this, &CMakeProject::handleActiveBuildConfigurationChanged);
|
||||||
|
connect(m_connectedTarget, &Target::kitChanged,
|
||||||
|
this, &CMakeProject::handleActiveBuildConfigurationChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleActiveBuildConfigurationChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMakeProject::handleActiveBuildConfigurationChanged()
|
void CMakeProject::handleActiveBuildConfigurationChanged()
|
||||||
@@ -483,7 +486,7 @@ void CMakeProject::handleActiveBuildConfigurationChanged()
|
|||||||
auto i = qobject_cast<CMakeBuildConfiguration *>(bc);
|
auto i = qobject_cast<CMakeBuildConfiguration *>(bc);
|
||||||
QTC_ASSERT(i, continue);
|
QTC_ASSERT(i, continue);
|
||||||
if (i == activeBc)
|
if (i == activeBc)
|
||||||
i->parse();
|
i->maybeForceReparse();
|
||||||
else
|
else
|
||||||
i->resetData();
|
i->resetData();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user