QbsProjectManager: Make project structure available faster.

So that users can navigate the project already while rule execution is
going on.

Change-Id: I88a6f0cf80bf208c418671e3b862e1defe8d86ab
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
This commit is contained in:
Christian Kandeler
2016-03-08 14:00:56 +01:00
parent a8b396b484
commit 83e3d954f9
4 changed files with 40 additions and 22 deletions

View File

@@ -431,6 +431,33 @@ bool QbsProject::needsSpecialDeployment() const
return true; return true;
} }
void QbsProject::handleProjectStructureAvailable()
{
QTC_ASSERT(m_qbsProjectParser, return);
bool dataChanged = false;
m_qbsProject = m_qbsProjectParser->qbsProject();
const qbs::ProjectData &projectData = m_qbsProject.projectData();
QTC_CHECK(m_qbsProject.isValid());
if (projectData != m_projectData) {
m_projectData = projectData;
rootProjectNode()->update();
updateDocuments(m_qbsProject.isValid()
? m_qbsProject.buildSystemFiles() : QSet<QString>() << projectFilePath().toString());
dataChanged = true;
}
if (dataChanged) {
auto * const futureInterface = m_qbsUpdateFutureInterface;
m_qbsUpdateFutureInterface = nullptr; // So that isParsing() returns false;
updateCppCodeModel();
updateQmlJsCodeModel();
emit fileListChanged();
m_qbsUpdateFutureInterface = futureInterface;
}
}
void QbsProject::handleQbsParsingDone(bool success) void QbsProject::handleQbsParsingDone(bool success)
{ {
QTC_ASSERT(m_qbsProjectParser, return); QTC_ASSERT(m_qbsProjectParser, return);
@@ -448,20 +475,9 @@ void QbsProject::handleQbsParsingDone(bool success)
generateErrors(m_qbsProjectParser->error()); generateErrors(m_qbsProjectParser->error());
bool dataChanged = false;
if (success) { if (success) {
m_qbsProject = m_qbsProjectParser->qbsProject(); QTC_ASSERT(m_qbsProject.isValid(), return);
const qbs::ProjectData &projectData = m_qbsProject.projectData(); m_projectData = m_qbsProject.projectData();
QTC_CHECK(m_qbsProject.isValid());
if (projectData != m_projectData) {
m_projectData = projectData;
rootProjectNode()->update();
updateDocuments(m_qbsProject.isValid()
? m_qbsProject.buildSystemFiles() : QSet<QString>() << projectFilePath().toString());
dataChanged = true;
}
} else { } else {
m_qbsUpdateFutureInterface->reportCanceled(); m_qbsUpdateFutureInterface->reportCanceled();
} }
@@ -475,13 +491,8 @@ void QbsProject::handleQbsParsingDone(bool success)
m_qbsUpdateFutureInterface = 0; m_qbsUpdateFutureInterface = 0;
} }
if (dataChanged) { // Do this now when isParsing() is false! if (success)
updateCppCodeModel();
updateQmlJsCodeModel();
updateBuildTargetData(); updateBuildTargetData();
emit fileListChanged();
}
emit projectParsingDone(success); emit projectParsingDone(success);
} }
@@ -593,9 +604,12 @@ void QbsProject::registerQbsProjectParser(QbsProjectParser *p)
m_qbsProjectParser = p; m_qbsProjectParser = p;
if (p) if (p) {
connect(m_qbsProjectParser, &QbsProjectParser::projectStructureAvailable,
this, &QbsProject::handleProjectStructureAvailable);
connect(m_qbsProjectParser, SIGNAL(done(bool)), this, SLOT(handleQbsParsingDone(bool))); connect(m_qbsProjectParser, SIGNAL(done(bool)), this, SLOT(handleQbsParsingDone(bool)));
} }
}
Project::RestoreResult QbsProject::fromMap(const QVariantMap &map, QString *errorMessage) Project::RestoreResult QbsProject::fromMap(const QVariantMap &map, QString *errorMessage)
{ {

View File

@@ -136,6 +136,7 @@ private:
void updateApplicationTargets(); void updateApplicationTargets();
void updateDeploymentInfo(); void updateDeploymentInfo();
void updateBuildTargetData(); void updateBuildTargetData();
void handleProjectStructureAvailable();
void projectLoaded() override; void projectLoaded() override;
static bool ensureWriteableQbsFile(const QString &file); static bool ensureWriteableQbsFile(const QString &file);

View File

@@ -143,11 +143,13 @@ void QbsProjectParser::handleQbsParsingDone(bool success)
// Do not report the operation as canceled here, as we might want to make overlapping // Do not report the operation as canceled here, as we might want to make overlapping
// parses appear atomic to the user. // parses appear atomic to the user.
if (!success) if (!success) {
emit done(false); emit done(false);
else } else {
emit projectStructureAvailable();
startRuleExecution(); startRuleExecution();
} }
}
void QbsProjectParser::startRuleExecution() void QbsProjectParser::startRuleExecution()
{ {

View File

@@ -55,6 +55,7 @@ public:
signals: signals:
void done(bool success); void done(bool success);
void projectStructureAvailable();
private slots: private slots:
void handleQbsParsingDone(bool success); void handleQbsParsingDone(bool success);