From e82a47e5afabd65bd6ebb5c39e1d31d4f3dfa9f9 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Thu, 17 Jul 2014 12:02:56 +0200 Subject: [PATCH] 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 --- .../qbsprojectmanager/qbsbuildstep.cpp | 2 +- src/plugins/qbsprojectmanager/qbsproject.cpp | 29 +++++------------ src/plugins/qbsprojectmanager/qbsproject.h | 4 +-- .../qbsprojectmanager/qbsprojectfile.cpp | 2 +- .../qbsprojectmanagerplugin.cpp | 2 +- .../qbsprojectmanager/qbsprojectparser.cpp | 32 ++----------------- .../qbsprojectmanager/qbsprojectparser.h | 5 +-- 7 files changed, 16 insertions(+), 60 deletions(-) diff --git a/src/plugins/qbsprojectmanager/qbsbuildstep.cpp b/src/plugins/qbsprojectmanager/qbsbuildstep.cpp index 9ee071ace64..92bfb71facd 100644 --- a/src/plugins/qbsprojectmanager/qbsbuildstep.cpp +++ b/src/plugins/qbsprojectmanager/qbsbuildstep.cpp @@ -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() diff --git a/src/plugins/qbsprojectmanager/qbsproject.cpp b/src/plugins/qbsprojectmanager/qbsproject.cpp index d9f7bc6a504..023a8b5a366 100644 --- a/src/plugins/qbsprojectmanager/qbsproject.cpp +++ b/src/plugins/qbsprojectmanager/qbsproject.cpp @@ -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,8 +469,8 @@ void QbsProject::parse(const QVariantMap &config, const Environment &env, const registerQbsProjectParser(new QbsProjectParser(this, m_qbsUpdateFutureInterface)); - if (m_qbsProjectParser->parse(config, env, dir)) - emit projectParsingStarted(); + m_qbsProjectParser->parse(config, env, dir); + emit projectParsingStarted(); } void QbsProject::prepareForParsing() diff --git a/src/plugins/qbsprojectmanager/qbsproject.h b/src/plugins/qbsprojectmanager/qbsproject.h index c2dde5d5a68..1f22cde680e 100644 --- a/src/plugins/qbsprojectmanager/qbsproject.h +++ b/src/plugins/qbsprojectmanager/qbsproject.h @@ -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 *m_qbsUpdateFutureInterface; - bool m_forceParsing; bool m_parsingScheduled; enum CancelStatus { diff --git a/src/plugins/qbsprojectmanager/qbsprojectfile.cpp b/src/plugins/qbsprojectmanager/qbsprojectfile.cpp index 5502462e7f5..65980fe9dab 100644 --- a/src/plugins/qbsprojectmanager/qbsprojectfile.cpp +++ b/src/plugins/qbsprojectmanager/qbsprojectfile.cpp @@ -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; } diff --git a/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp b/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp index 68bfec5291f..4cc2cbb8a13 100644 --- a/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp +++ b/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp @@ -522,7 +522,7 @@ void QbsProjectManagerPlugin::reparseProject(QbsProject *project) if (BuildManager::isBuilding(project)) project->scheduleParsing(); else - project->parseCurrentBuildConfiguration(true); + project->parseCurrentBuildConfiguration(); } } // namespace Internal diff --git a/src/plugins/qbsprojectmanager/qbsprojectparser.cpp b/src/plugins/qbsprojectmanager/qbsprojectparser.cpp index b43d8d4dd27..45e00d92cb9 100644 --- a/src/plugins/qbsprojectmanager/qbsprojectparser.cpp +++ b/src/plugins/qbsprojectmanager/qbsprojectparser.cpp @@ -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 usedEnv = m_project.usedEnvironment(); - for (QHash::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() diff --git a/src/plugins/qbsprojectmanager/qbsprojectparser.h b/src/plugins/qbsprojectmanager/qbsprojectparser.h index 9d0d1496aec..da7b9dbc74c 100644 --- a/src/plugins/qbsprojectmanager/qbsprojectparser.h +++ b/src/plugins/qbsprojectmanager/qbsprojectparser.h @@ -51,9 +51,7 @@ public: QFutureInterface *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;