Commit 9db57f3f authored by Tobias Hunger's avatar Tobias Hunger

Qbs: Delay reparsing of the project

Makes the whole thing feel more responsive:-)

Change-Id: I1b3941ab42bb1a281c0923e3826b00d1f1400abe
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent cbcd0bee
......@@ -105,6 +105,8 @@ QbsProject::QbsProject(QbsManager *manager, const QString &fileName) :
m_qbsUpdateFutureInterface(0),
m_currentBc(0)
{
m_parsingDelay.setInterval(1000); // delay (some) parsing by 1s.
setProjectContext(Core::Context(Constants::PROJECT_ID));
setProjectLanguages(Core::Context(ProjectExplorer::Constants::LANG_CXX));
......@@ -112,7 +114,9 @@ QbsProject::QbsProject(QbsManager *manager, const QString &fileName) :
this, SLOT(changeActiveTarget(ProjectExplorer::Target*)));
connect(this, SIGNAL(addedTarget(ProjectExplorer::Target*)),
this, SLOT(targetWasAdded(ProjectExplorer::Target*)));
connect(this, SIGNAL(environmentChanged()), this, SLOT(parseCurrentBuildConfiguration()));
connect(this, SIGNAL(environmentChanged()), this, SLOT(delayParsing()));
connect(&m_parsingDelay, SIGNAL(timeout()), this, SLOT(parseCurrentBuildConfiguration()));
updateDocuments(0);
m_rootProjectNode = new QbsProjectNode(this); // needs documents to be initialized!
......@@ -287,9 +291,8 @@ void QbsProject::handleQbsParsingTaskSetup(const QString &description, int maxim
void QbsProject::targetWasAdded(ProjectExplorer::Target *t)
{
connect(t, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)),
this, SLOT(parseCurrentBuildConfiguration()));
connect(t, SIGNAL(buildDirectoryChanged()),
this, SLOT(parseCurrentBuildConfiguration()));
this, SLOT(delayParsing()));
connect(t, SIGNAL(buildDirectoryChanged()), this, SLOT(delayParsing()));
}
void QbsProject::changeActiveTarget(ProjectExplorer::Target *t)
......@@ -303,19 +306,26 @@ void QbsProject::changeActiveTarget(ProjectExplorer::Target *t)
void QbsProject::buildConfigurationChanged(ProjectExplorer::BuildConfiguration *bc)
{
if (m_currentBc)
disconnect(m_currentBc, SIGNAL(qbsConfigurationChanged()), this, SLOT(parseCurrentBuildConfiguration()));
disconnect(m_currentBc, SIGNAL(qbsConfigurationChanged()), this, SLOT(delayParsing()));
m_currentBc = qobject_cast<QbsBuildConfiguration *>(bc);
if (m_currentBc) {
connect(m_currentBc, SIGNAL(qbsConfigurationChanged()), this, SLOT(parseCurrentBuildConfiguration()));
parseCurrentBuildConfiguration();
connect(m_currentBc, SIGNAL(qbsConfigurationChanged()), this, SLOT(delayParsing()));
delayParsing();
} else {
invalidate();
}
}
void QbsProject::delayParsing()
{
m_parsingDelay.start();
}
void QbsProject::parseCurrentBuildConfiguration()
{
m_parsingDelay.stop();
if (!activeTarget())
return;
QbsBuildConfiguration *bc = qobject_cast<QbsBuildConfiguration *>(activeTarget()->activeBuildConfiguration());
......
......@@ -42,9 +42,7 @@
#include <utils/environment.h>
#include <QFuture>
// <debug>
#include <QTimer>
// </debug>
#include <QVariantMap>
namespace qbs {
......@@ -101,6 +99,7 @@ public:
public slots:
void invalidate();
void parseCurrentBuildConfiguration();
void delayParsing();
signals:
void projectParsingStarted();
......@@ -141,6 +140,8 @@ private:
QFuture<void> m_codeModelFuture;
QbsBuildConfiguration *m_currentBc;
QTimer m_parsingDelay;
};
} // namespace Internal
......
......@@ -96,7 +96,7 @@ bool QbsProjectFile::reload(QString *errorString, ReloadFlag flag, ChangeType ty
Q_UNUSED(flag)
if (type == TypePermissions)
return true;
m_project->parseCurrentBuildConfiguration();
m_project->delayParsing();
return true;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment