QbsProjectManager: No more "forced" vs "non-forced" parsing.

This differentiation complicates the code and duplicates checks
already done in qbs.
Just let the library reparse the project; if it turns out that nothing
has to be done, then the operation will be fast.

Change-Id: Ib6406f254e51541c69c948f275fff7877b65b4bd
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
This commit is contained in:
Christian Kandeler
2014-07-17 12:02:56 +02:00
parent 35940f16e4
commit e82a47e5af
7 changed files with 16 additions and 60 deletions

View File

@@ -365,7 +365,7 @@ void QbsBuildStep::parseProject()
{
m_parsingProject = true;
connect(qbsProject(), SIGNAL(projectParsingDone(bool)), SLOT(reparsingDone(bool)));
qbsProject()->parseCurrentBuildConfiguration(true);
qbsProject()->parseCurrentBuildConfiguration();
}
void QbsBuildStep::build()

View File

@@ -100,7 +100,6 @@ QbsProject::QbsProject(QbsManager *manager, const QString &fileName) :
m_rootProjectNode(0),
m_qbsProjectParser(0),
m_qbsUpdateFutureInterface(0),
m_forceParsing(false),
m_parsingScheduled(false),
m_cancelStatus(CancelStatusNone),
m_currentBc(0)
@@ -283,7 +282,7 @@ void QbsProject::handleQbsParsingDone(bool success)
if (cancelStatus == CancelStatusCancelingForReparse) {
m_qbsProjectParser->deleteLater();
m_qbsProjectParser = 0;
parseCurrentBuildConfiguration(m_forceParsing);
parseCurrentBuildConfiguration();
return;
}
@@ -316,8 +315,8 @@ void QbsProject::handleQbsParsingDone(bool success)
void QbsProject::targetWasAdded(Target *t)
{
connect(t, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)),
this, SLOT(delayForcedParsing()));
connect(t, SIGNAL(buildDirectoryChanged()), this, SLOT(delayForcedParsing()));
this, SLOT(delayParsing()));
connect(t, SIGNAL(buildDirectoryChanged()), this, SLOT(delayParsing()));
}
void QbsProject::changeActiveTarget(Target *t)
@@ -351,7 +350,7 @@ void QbsProject::startParsing()
return;
}
parseCurrentBuildConfiguration(false);
parseCurrentBuildConfiguration();
}
void QbsProject::delayParsing()
@@ -359,12 +358,6 @@ void QbsProject::delayParsing()
m_parsingDelay.start();
}
void QbsProject::delayForcedParsing()
{
m_forceParsing = true;
delayParsing();
}
// Qbs may change its data
void QbsProject::readQbsData()
{
@@ -383,11 +376,9 @@ void QbsProject::readQbsData()
emit fileListChanged();
}
void QbsProject::parseCurrentBuildConfiguration(bool force)
void QbsProject::parseCurrentBuildConfiguration()
{
m_parsingScheduled = false;
if (!m_forceParsing)
m_forceParsing = force;
if (m_cancelStatus == CancelStatusCancelingForReparse)
return;
@@ -440,12 +431,8 @@ void QbsProject::registerQbsProjectParser(QbsProjectParser *p)
m_qbsProjectParser = p;
if (p) {
p->setForced(m_forceParsing);
if (p)
connect(m_qbsProjectParser, SIGNAL(done(bool)), this, SLOT(handleQbsParsingDone(bool)));
}
m_forceParsing = false;
}
bool QbsProject::fromMap(const QVariantMap &map)
@@ -482,7 +469,7 @@ void QbsProject::parse(const QVariantMap &config, const Environment &env, const
registerQbsProjectParser(new QbsProjectParser(this, m_qbsUpdateFutureInterface));
if (m_qbsProjectParser->parse(config, env, dir))
m_qbsProjectParser->parse(config, env, dir);
emit projectParsingStarted();
}

View File

@@ -93,7 +93,7 @@ public:
QString profileForTarget(const ProjectExplorer::Target *t) const;
bool isParsing() const;
bool hasParseResult() const;
void parseCurrentBuildConfiguration(bool force);
void parseCurrentBuildConfiguration();
void scheduleParsing() { m_parsingScheduled = true; }
bool parsingScheduled() const { return m_parsingScheduled; }
void cancelParsing();
@@ -114,7 +114,6 @@ public:
public slots:
void invalidate();
void delayParsing();
void delayForcedParsing();
void readQbsData();
signals:
@@ -153,7 +152,6 @@ private:
QbsProjectParser *m_qbsProjectParser;
QFutureInterface<bool> *m_qbsUpdateFutureInterface;
bool m_forceParsing;
bool m_parsingScheduled;
enum CancelStatus {

View File

@@ -89,7 +89,7 @@ bool QbsProjectFile::reload(QString *errorString, ReloadFlag flag, ChangeType ty
Q_UNUSED(flag)
if (type == TypePermissions)
return true;
m_project->delayForcedParsing();
m_project->delayParsing();
return true;
}

View File

@@ -522,7 +522,7 @@ void QbsProjectManagerPlugin::reparseProject(QbsProject *project)
if (BuildManager::isBuilding(project))
project->scheduleParsing();
else
project->parseCurrentBuildConfiguration(true);
project->parseCurrentBuildConfiguration();
}
} // namespace Internal

View File

@@ -71,15 +71,10 @@ QbsProjectParser::~QbsProjectParser()
m_fi = 0; // we do not own m_fi, do not delete
}
void QbsProjectParser::setForced(bool f)
void QbsProjectParser::parse(const QVariantMap &config, const Environment &env, const QString &dir)
{
m_wasForced = f;
}
bool QbsProjectParser::parse(const QVariantMap &config, const Environment &env, const QString &dir)
{
QTC_ASSERT(!m_qbsSetupProjectJob, return false);
QTC_ASSERT(!dir.isNull(), return false);
QTC_ASSERT(!m_qbsSetupProjectJob, return);
QTC_ASSERT(!dir.isEmpty(), return);
m_currentProgressBase = 0;
@@ -92,25 +87,6 @@ bool QbsProjectParser::parse(const QVariantMap &config, const Environment &env,
params.setBuildVariant(userConfig.take(specialKey).toString());
params.setSettingsDirectory(QbsManager::settings()->baseDirectoy());
params.setOverriddenValues(userConfig);
m_error = params.expandBuildConfiguration();
if (m_error.hasError()) {
emit done(false);
return false;
}
// Avoid useless reparsing:
if (!m_wasForced
&& m_project.isValid()
&& m_project.projectConfiguration() == params.finalBuildConfigurationTree()) {
QHash<QString, QString> usedEnv = m_project.usedEnvironment();
for (QHash<QString, QString>::const_iterator i = usedEnv.constBegin();
i != usedEnv.constEnd(); ++i) {
if (env.value(i.key()) != i.value()) {
emit done(true);
return true;
}
}
}
// Some people don't like it when files are created as a side effect of opening a project,
// so do not store the build graph if the build directory does not exist yet.
@@ -132,8 +108,6 @@ bool QbsProjectParser::parse(const QVariantMap &config, const Environment &env,
this, SLOT(handleQbsParsingTaskSetup(QString,int)));
connect(m_qbsSetupProjectJob, SIGNAL(taskProgress(int,qbs::AbstractJob*)),
this, SLOT(handleQbsParsingProgress(int)));
return true;
}
void QbsProjectParser::cancel()

View File

@@ -51,9 +51,7 @@ public:
QFutureInterface<bool> *fi);
~QbsProjectParser();
void setForced(bool);
bool parse(const QVariantMap &config, const Utils::Environment &env, const QString &dir);
void parse(const QVariantMap &config, const Utils::Environment &env, const QString &dir);
void cancel();
qbs::Project qbsProject() const;
@@ -71,7 +69,6 @@ private:
QString pluginsBaseDirectory() const;
QString resourcesBaseDirectory() const;
bool m_wasForced;
QString m_projectFilePath;
qbs::SetupProjectJob *m_qbsSetupProjectJob;
qbs::ErrorInfo m_error;