QmakeProject: Make initial parse use the async parsing

Task-number: QTCREATORBUG-12123
Change-Id: I79dcd684fe826108189db521c392c0f1d7632f88
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
Daniel Teske
2014-09-26 15:24:32 +02:00
parent 742e14f1e9
commit cb068421b9
4 changed files with 30 additions and 68 deletions

View File

@@ -1750,14 +1750,6 @@ EvalInput QmakeProFileNode::evalInput() const
return input; return input;
} }
void QmakeProFileNode::update()
{
setParseInProgressRecursive(true);
setupReader();
EvalResult *evalResult = evaluate(evalInput());
applyEvaluate(evalResult, false);
}
void QmakeProFileNode::setupReader() void QmakeProFileNode::setupReader()
{ {
Q_ASSERT(!m_readerExact); Q_ASSERT(!m_readerExact);
@@ -2005,7 +1997,7 @@ void QmakeProFileNode::asyncEvaluate(QFutureInterface<EvalResult *> &fi, EvalInp
void QmakeProFileNode::applyAsyncEvaluate() void QmakeProFileNode::applyAsyncEvaluate()
{ {
applyEvaluate(m_parseFutureWatcher.result(), true); applyEvaluate(m_parseFutureWatcher.result());
m_project->decrementPendingEvaluateFutures(); m_project->decrementPendingEvaluateFutures();
} }
@@ -2014,7 +2006,7 @@ bool sortByNodes(Node *a, Node *b)
return a->path() < b->path(); return a->path() < b->path();
} }
void QmakeProFileNode::applyEvaluate(EvalResult *evalResult, bool async) void QmakeProFileNode::applyEvaluate(EvalResult *evalResult)
{ {
QScopedPointer<EvalResult> result(evalResult); QScopedPointer<EvalResult> result(evalResult);
if (!m_readerExact) if (!m_readerExact)
@@ -2175,10 +2167,7 @@ void QmakeProFileNode::applyEvaluate(EvalResult *evalResult, bool async)
// So to compare that later parse with the sync one // So to compare that later parse with the sync one
QmakeProFileNode *proFileNode = static_cast<QmakeProFileNode *>(*existingIt); QmakeProFileNode *proFileNode = static_cast<QmakeProFileNode *>(*existingIt);
proFileNode->setIncludedInExactParse(result->exactSubdirs.contains(proFileNode->path()) && includedInExactParse()); proFileNode->setIncludedInExactParse(result->exactSubdirs.contains(proFileNode->path()) && includedInExactParse());
if (async)
proFileNode->asyncUpdate(); proFileNode->asyncUpdate();
else
proFileNode->update();
} }
++existingIt; ++existingIt;
// newCumalativeIt and newExactIt are already incremented // 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 *qmakeProFileNode = new QmakeProFileNode(m_project, nodeToAdd);
qmakeProFileNode->setParentFolderNode(this); // Needed for loop detection qmakeProFileNode->setParentFolderNode(this); // Needed for loop detection
qmakeProFileNode->setIncludedInExactParse(result->exactSubdirs.contains(qmakeProFileNode->path()) && includedInExactParse()); qmakeProFileNode->setIncludedInExactParse(result->exactSubdirs.contains(qmakeProFileNode->path()) && includedInExactParse());
if (async)
qmakeProFileNode->asyncUpdate(); qmakeProFileNode->asyncUpdate();
else
qmakeProFileNode->update();
toAdd << qmakeProFileNode; toAdd << qmakeProFileNode;
} }
} }

View File

@@ -416,7 +416,6 @@ public:
bool isDeployable() const; bool isDeployable() const;
QString resolvedMkspecPath() const; QString resolvedMkspecPath() const;
void update();
void scheduleUpdate(); void scheduleUpdate();
bool validParse() const; bool validParse() const;
@@ -442,7 +441,7 @@ private:
Internal::EvalInput evalInput() const; Internal::EvalInput evalInput() const;
static Internal::EvalResult *evaluate(const Internal::EvalInput &input); static Internal::EvalResult *evaluate(const Internal::EvalInput &input);
void applyEvaluate(Internal::EvalResult *parseResult, bool async); void applyEvaluate(Internal::EvalResult *parseResult);
void asyncEvaluate(QFutureInterface<Internal::EvalResult *> &fi, Internal::EvalInput input); void asyncEvaluate(QFutureInterface<Internal::EvalResult *> &fi, Internal::EvalInput input);

View File

@@ -346,10 +346,11 @@ QmakeProject::QmakeProject(QmakeManager *manager, const QString &fileName) :
m_qmakeGlobalsRefCnt(0), m_qmakeGlobalsRefCnt(0),
m_asyncUpdateFutureInterface(0), m_asyncUpdateFutureInterface(0),
m_pendingEvaluateFuturesCount(0), m_pendingEvaluateFuturesCount(0),
m_asyncUpdateState(NoState), m_asyncUpdateState(Base),
m_cancelEvaluate(false), m_cancelEvaluate(false),
m_centralizedFolderWatcher(0), m_centralizedFolderWatcher(0),
m_activeTarget(0) m_activeTarget(0),
m_checkForTemplateUpdate(true)
{ {
setId(Constants::QMAKEPROJECT_ID); setId(Constants::QMAKEPROJECT_ID);
setProjectContext(Core::Context(QmakeProjectManager::Constants::PROJECT_ID)); setProjectContext(Core::Context(QmakeProjectManager::Constants::PROJECT_ID));
@@ -357,7 +358,7 @@ QmakeProject::QmakeProject(QmakeManager *manager, const QString &fileName) :
setRequiredKitMatcher(QtSupport::QtKitInformation::qtVersionMatcher()); setRequiredKitMatcher(QtSupport::QtKitInformation::qtVersionMatcher());
m_asyncUpdateTimer.setSingleShot(true); 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(&m_asyncUpdateTimer, SIGNAL(timeout()), this, SLOT(asyncUpdate()));
connect(BuildManager::instance(), SIGNAL(buildQueueFinished(bool)), 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 = new QmakeProFileNode(this, m_fileInfo->filePath(), this);
m_rootProjectNode->registerWatcher(m_nodesWatcher); 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! // We have the profile nodes now, so we know the runconfigs!
connect(m_nodesWatcher, SIGNAL(proFileUpdated(QmakeProjectManager::QmakeProFileNode*,bool,bool)), connect(m_nodesWatcher, SIGNAL(proFileUpdated(QmakeProjectManager::QmakeProFileNode*,bool,bool)),
this, 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 // On active buildconfiguration changes, reevaluate the .pro files
m_activeTarget = activeTarget(); m_activeTarget = activeTarget();
if (m_activeTarget) if (m_activeTarget)
@@ -433,17 +426,8 @@ bool QmakeProject::fromMap(const QVariantMap &map)
connect(this, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)), connect(this, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)),
this, SLOT(activeTargetWasChanged())); this, SLOT(activeTargetWasChanged()));
// // Update boiler plate code for subprojects. scheduleAsyncUpdate();
QtQuickApp qtQuickApp; m_asyncUpdateTimer.setInterval(3000);
foreach (QmakeProFileNode *node, applicationProFiles(QmakeProject::ExactAndCumulativeParse)) {
const QString path = node->path();
foreach (TemplateInfo info, QtQuickApp::templateInfos()) {
qtQuickApp.setTemplateInfo(info);
updateBoilerPlateCodeFiles(&qtQuickApp, path);
}
}
return true; return true;
} }
@@ -674,26 +658,6 @@ void QmakeProject::updateQmlJSCodeModel()
modelManager->updateProjectInfo(projectInfo, this); 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() void QmakeProject::updateRunConfigurations()
{ {
if (activeTarget()) if (activeTarget())
@@ -707,7 +671,6 @@ void QmakeProject::scheduleAsyncUpdate(QmakeProFileNode *node)
if (debug) if (debug)
qDebug()<<"schduleAsyncUpdate (node)"<<node->path(); qDebug()<<"schduleAsyncUpdate (node)"<<node->path();
Q_ASSERT(m_asyncUpdateState != NoState);
if (m_cancelEvaluate) { if (m_cancelEvaluate) {
if (debug) if (debug)
@@ -779,7 +742,6 @@ void QmakeProject::scheduleAsyncUpdate()
if (m_asyncUpdateState == ShuttingDown) if (m_asyncUpdateState == ShuttingDown)
return; return;
Q_ASSERT(m_asyncUpdateState != NoState);
if (m_cancelEvaluate) { // we are in progress of canceling if (m_cancelEvaluate) { // we are in progress of canceling
// and will start the evaluation after that // and will start the evaluation after that
if (debug) if (debug)
@@ -858,6 +820,22 @@ void QmakeProject::decrementPendingEvaluateFutures()
if (debug) if (debug)
qDebug()<<" Setting state to Base"; 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); findProFile(name, rootQmakeProjectNode(), list);
foreach (QmakeProFileNode *node, list) { foreach (QmakeProFileNode *node, list) {
QtSupport::ProFileCacheManager::instance()->discardFile(name); QtSupport::ProFileCacheManager::instance()->discardFile(name);
node->update(); node->scheduleUpdate();
} }
updateFileList();
} }
} }

View File

@@ -149,7 +149,6 @@ signals:
public slots: public slots:
void scheduleAsyncUpdate(); void scheduleAsyncUpdate();
void update();
protected: protected:
bool fromMap(const QVariantMap &map); bool fromMap(const QVariantMap &map);
@@ -203,7 +202,7 @@ private:
QTimer m_asyncUpdateTimer; QTimer m_asyncUpdateTimer;
QFutureInterface<void> *m_asyncUpdateFutureInterface; QFutureInterface<void> *m_asyncUpdateFutureInterface;
int m_pendingEvaluateFuturesCount; int m_pendingEvaluateFuturesCount;
enum AsyncUpdateState { NoState, Base, AsyncFullUpdatePending, AsyncPartialUpdatePending, AsyncUpdateInProgress, ShuttingDown }; enum AsyncUpdateState { Base, AsyncFullUpdatePending, AsyncPartialUpdatePending, AsyncUpdateInProgress, ShuttingDown };
AsyncUpdateState m_asyncUpdateState; AsyncUpdateState m_asyncUpdateState;
bool m_cancelEvaluate; bool m_cancelEvaluate;
QList<QmakeProFileNode *> m_partialEvaluate; QList<QmakeProFileNode *> m_partialEvaluate;
@@ -213,6 +212,7 @@ private:
Internal::CentralizedFolderWatcher *m_centralizedFolderWatcher; Internal::CentralizedFolderWatcher *m_centralizedFolderWatcher;
ProjectExplorer::Target *m_activeTarget; ProjectExplorer::Target *m_activeTarget;
bool m_checkForTemplateUpdate; // initialized to true, set to false after first parse
friend class Internal::QmakeProjectFile; friend class Internal::QmakeProjectFile;
friend class Internal::QmakeProjectConfigWidget; friend class Internal::QmakeProjectConfigWidget;