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; m_parsingProject = true;
connect(qbsProject(), SIGNAL(projectParsingDone(bool)), SLOT(reparsingDone(bool))); connect(qbsProject(), SIGNAL(projectParsingDone(bool)), SLOT(reparsingDone(bool)));
qbsProject()->parseCurrentBuildConfiguration(true); qbsProject()->parseCurrentBuildConfiguration();
} }
void QbsBuildStep::build() void QbsBuildStep::build()

View File

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

View File

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

View File

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

View File

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

View File

@@ -71,15 +71,10 @@ QbsProjectParser::~QbsProjectParser()
m_fi = 0; // we do not own m_fi, do not delete 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; QTC_ASSERT(!m_qbsSetupProjectJob, return);
} QTC_ASSERT(!dir.isEmpty(), return);
bool QbsProjectParser::parse(const QVariantMap &config, const Environment &env, const QString &dir)
{
QTC_ASSERT(!m_qbsSetupProjectJob, return false);
QTC_ASSERT(!dir.isNull(), return false);
m_currentProgressBase = 0; m_currentProgressBase = 0;
@@ -92,25 +87,6 @@ bool QbsProjectParser::parse(const QVariantMap &config, const Environment &env,
params.setBuildVariant(userConfig.take(specialKey).toString()); params.setBuildVariant(userConfig.take(specialKey).toString());
params.setSettingsDirectory(QbsManager::settings()->baseDirectoy()); params.setSettingsDirectory(QbsManager::settings()->baseDirectoy());
params.setOverriddenValues(userConfig); 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, // 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. // 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))); this, SLOT(handleQbsParsingTaskSetup(QString,int)));
connect(m_qbsSetupProjectJob, SIGNAL(taskProgress(int,qbs::AbstractJob*)), connect(m_qbsSetupProjectJob, SIGNAL(taskProgress(int,qbs::AbstractJob*)),
this, SLOT(handleQbsParsingProgress(int))); this, SLOT(handleQbsParsingProgress(int)));
return true;
} }
void QbsProjectParser::cancel() void QbsProjectParser::cancel()

View File

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