From cb068421b98b59a4ce7f31fafd942f88315dec30 Mon Sep 17 00:00:00 2001 From: Daniel Teske Date: Fri, 26 Sep 2014 15:24:32 +0200 Subject: [PATCH] QmakeProject: Make initial parse use the async parsing Task-number: QTCREATORBUG-12123 Change-Id: I79dcd684fe826108189db521c392c0f1d7632f88 Reviewed-by: Tobias Hunger --- .../qmakeprojectmanager/qmakenodes.cpp | 22 ++---- src/plugins/qmakeprojectmanager/qmakenodes.h | 3 +- .../qmakeprojectmanager/qmakeproject.cpp | 69 +++++++------------ .../qmakeprojectmanager/qmakeproject.h | 4 +- 4 files changed, 30 insertions(+), 68 deletions(-) diff --git a/src/plugins/qmakeprojectmanager/qmakenodes.cpp b/src/plugins/qmakeprojectmanager/qmakenodes.cpp index a6ce53f4505..4b03dfab5ec 100644 --- a/src/plugins/qmakeprojectmanager/qmakenodes.cpp +++ b/src/plugins/qmakeprojectmanager/qmakenodes.cpp @@ -1750,14 +1750,6 @@ EvalInput QmakeProFileNode::evalInput() const return input; } -void QmakeProFileNode::update() -{ - setParseInProgressRecursive(true); - setupReader(); - EvalResult *evalResult = evaluate(evalInput()); - applyEvaluate(evalResult, false); -} - void QmakeProFileNode::setupReader() { Q_ASSERT(!m_readerExact); @@ -2005,7 +1997,7 @@ void QmakeProFileNode::asyncEvaluate(QFutureInterface &fi, EvalInp void QmakeProFileNode::applyAsyncEvaluate() { - applyEvaluate(m_parseFutureWatcher.result(), true); + applyEvaluate(m_parseFutureWatcher.result()); m_project->decrementPendingEvaluateFutures(); } @@ -2014,7 +2006,7 @@ bool sortByNodes(Node *a, Node *b) return a->path() < b->path(); } -void QmakeProFileNode::applyEvaluate(EvalResult *evalResult, bool async) +void QmakeProFileNode::applyEvaluate(EvalResult *evalResult) { QScopedPointer result(evalResult); if (!m_readerExact) @@ -2175,10 +2167,7 @@ void QmakeProFileNode::applyEvaluate(EvalResult *evalResult, bool async) // So to compare that later parse with the sync one QmakeProFileNode *proFileNode = static_cast(*existingIt); proFileNode->setIncludedInExactParse(result->exactSubdirs.contains(proFileNode->path()) && includedInExactParse()); - if (async) - proFileNode->asyncUpdate(); - else - proFileNode->update(); + proFileNode->asyncUpdate(); } ++existingIt; // newCumalativeIt and newExactIt are already incremented @@ -2211,10 +2200,7 @@ void QmakeProFileNode::applyEvaluate(EvalResult *evalResult, bool async) QmakeProFileNode *qmakeProFileNode = new QmakeProFileNode(m_project, nodeToAdd); qmakeProFileNode->setParentFolderNode(this); // Needed for loop detection qmakeProFileNode->setIncludedInExactParse(result->exactSubdirs.contains(qmakeProFileNode->path()) && includedInExactParse()); - if (async) - qmakeProFileNode->asyncUpdate(); - else - qmakeProFileNode->update(); + qmakeProFileNode->asyncUpdate(); toAdd << qmakeProFileNode; } } diff --git a/src/plugins/qmakeprojectmanager/qmakenodes.h b/src/plugins/qmakeprojectmanager/qmakenodes.h index c3a0381792b..69e571319b3 100644 --- a/src/plugins/qmakeprojectmanager/qmakenodes.h +++ b/src/plugins/qmakeprojectmanager/qmakenodes.h @@ -416,7 +416,6 @@ public: bool isDeployable() const; QString resolvedMkspecPath() const; - void update(); void scheduleUpdate(); bool validParse() const; @@ -442,7 +441,7 @@ private: Internal::EvalInput evalInput() const; static Internal::EvalResult *evaluate(const Internal::EvalInput &input); - void applyEvaluate(Internal::EvalResult *parseResult, bool async); + void applyEvaluate(Internal::EvalResult *parseResult); void asyncEvaluate(QFutureInterface &fi, Internal::EvalInput input); diff --git a/src/plugins/qmakeprojectmanager/qmakeproject.cpp b/src/plugins/qmakeprojectmanager/qmakeproject.cpp index 0263e15994b..60c90adb21c 100644 --- a/src/plugins/qmakeprojectmanager/qmakeproject.cpp +++ b/src/plugins/qmakeprojectmanager/qmakeproject.cpp @@ -346,10 +346,11 @@ QmakeProject::QmakeProject(QmakeManager *manager, const QString &fileName) : m_qmakeGlobalsRefCnt(0), m_asyncUpdateFutureInterface(0), m_pendingEvaluateFuturesCount(0), - m_asyncUpdateState(NoState), + m_asyncUpdateState(Base), m_cancelEvaluate(false), m_centralizedFolderWatcher(0), - m_activeTarget(0) + m_activeTarget(0), + m_checkForTemplateUpdate(true) { setId(Constants::QMAKEPROJECT_ID); setProjectContext(Core::Context(QmakeProjectManager::Constants::PROJECT_ID)); @@ -357,7 +358,7 @@ QmakeProject::QmakeProject(QmakeManager *manager, const QString &fileName) : setRequiredKitMatcher(QtSupport::QtKitInformation::qtVersionMatcher()); m_asyncUpdateTimer.setSingleShot(true); - m_asyncUpdateTimer.setInterval(3000); + m_asyncUpdateTimer.setInterval(0); // will be increased after first parse connect(&m_asyncUpdateTimer, SIGNAL(timeout()), this, SLOT(asyncUpdate())); connect(BuildManager::instance(), SIGNAL(buildQueueFinished(bool)), @@ -412,18 +413,10 @@ bool QmakeProject::fromMap(const QVariantMap &map) m_rootProjectNode = new QmakeProFileNode(this, m_fileInfo->filePath(), this); m_rootProjectNode->registerWatcher(m_nodesWatcher); - update(); - updateFileList(); - // This might be incorrect, need a full update - updateCodeModels(); - // We have the profile nodes now, so we know the runconfigs! connect(m_nodesWatcher, SIGNAL(proFileUpdated(QmakeProjectManager::QmakeProFileNode*,bool,bool)), this, SIGNAL(proFileUpdated(QmakeProjectManager::QmakeProFileNode*,bool,bool))); - // Now we emit update once :) - m_rootProjectNode->emitProFileUpdatedRecursive(); - // On active buildconfiguration changes, reevaluate the .pro files m_activeTarget = activeTarget(); if (m_activeTarget) @@ -433,17 +426,8 @@ bool QmakeProject::fromMap(const QVariantMap &map) connect(this, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)), this, SLOT(activeTargetWasChanged())); - // // Update boiler plate code for subprojects. - QtQuickApp qtQuickApp; - - foreach (QmakeProFileNode *node, applicationProFiles(QmakeProject::ExactAndCumulativeParse)) { - const QString path = node->path(); - - foreach (TemplateInfo info, QtQuickApp::templateInfos()) { - qtQuickApp.setTemplateInfo(info); - updateBoilerPlateCodeFiles(&qtQuickApp, path); - } - } + scheduleAsyncUpdate(); + m_asyncUpdateTimer.setInterval(3000); return true; } @@ -674,26 +658,6 @@ void QmakeProject::updateQmlJSCodeModel() modelManager->updateProjectInfo(projectInfo, this); } -///*! -// Updates complete project -// */ -void QmakeProject::update() -{ - if (debug) - qDebug()<<"Doing sync update"; - m_rootProjectNode->update(); - - if (debug) - qDebug()<<"State is now Base"; - m_asyncUpdateState = Base; - enableActiveQmakeBuildConfiguration(activeTarget(), true); - updateBuildSystemData(); - if (activeTarget()) - activeTarget()->updateDefaultDeployConfigurations(); - updateRunConfigurations(); - emit proFilesEvaluated(); -} - void QmakeProject::updateRunConfigurations() { if (activeTarget()) @@ -707,7 +671,6 @@ void QmakeProject::scheduleAsyncUpdate(QmakeProFileNode *node) if (debug) qDebug()<<"schduleAsyncUpdate (node)"<path(); - Q_ASSERT(m_asyncUpdateState != NoState); if (m_cancelEvaluate) { if (debug) @@ -779,7 +742,6 @@ void QmakeProject::scheduleAsyncUpdate() if (m_asyncUpdateState == ShuttingDown) return; - Q_ASSERT(m_asyncUpdateState != NoState); if (m_cancelEvaluate) { // we are in progress of canceling // and will start the evaluation after that if (debug) @@ -858,6 +820,22 @@ void QmakeProject::decrementPendingEvaluateFutures() if (debug) qDebug()<<" Setting state to Base"; } + + if (m_checkForTemplateUpdate) { + // Update boiler plate code for subprojects. + QtQuickApp qtQuickApp; + + foreach (QmakeProFileNode *node, applicationProFiles(QmakeProject::ExactAndCumulativeParse)) { + const QString path = node->path(); + + foreach (TemplateInfo info, QtQuickApp::templateInfos()) { + qtQuickApp.setTemplateInfo(info); + updateBoilerPlateCodeFiles(&qtQuickApp, path); + } + } + m_checkForTemplateUpdate = false; + } + } } @@ -1210,9 +1188,8 @@ void QmakeProject::notifyChanged(const QString &name) findProFile(name, rootQmakeProjectNode(), list); foreach (QmakeProFileNode *node, list) { QtSupport::ProFileCacheManager::instance()->discardFile(name); - node->update(); + node->scheduleUpdate(); } - updateFileList(); } } diff --git a/src/plugins/qmakeprojectmanager/qmakeproject.h b/src/plugins/qmakeprojectmanager/qmakeproject.h index 43541b86287..440a639f2b4 100644 --- a/src/plugins/qmakeprojectmanager/qmakeproject.h +++ b/src/plugins/qmakeprojectmanager/qmakeproject.h @@ -149,7 +149,6 @@ signals: public slots: void scheduleAsyncUpdate(); - void update(); protected: bool fromMap(const QVariantMap &map); @@ -203,7 +202,7 @@ private: QTimer m_asyncUpdateTimer; QFutureInterface *m_asyncUpdateFutureInterface; int m_pendingEvaluateFuturesCount; - enum AsyncUpdateState { NoState, Base, AsyncFullUpdatePending, AsyncPartialUpdatePending, AsyncUpdateInProgress, ShuttingDown }; + enum AsyncUpdateState { Base, AsyncFullUpdatePending, AsyncPartialUpdatePending, AsyncUpdateInProgress, ShuttingDown }; AsyncUpdateState m_asyncUpdateState; bool m_cancelEvaluate; QList m_partialEvaluate; @@ -213,6 +212,7 @@ private: Internal::CentralizedFolderWatcher *m_centralizedFolderWatcher; ProjectExplorer::Target *m_activeTarget; + bool m_checkForTemplateUpdate; // initialized to true, set to false after first parse friend class Internal::QmakeProjectFile; friend class Internal::QmakeProjectConfigWidget;