aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/corelib/api/jobs.cpp
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@digia.com>2014-07-15 11:42:56 +0200
committerChristian Kandeler <christian.kandeler@digia.com>2014-07-16 14:05:23 +0200
commit05ef86ccaf7a4be0737f0af0bf61c69bd6f2e97a (patch)
tree814f7fd3b1b3090b400ef706a24b8cee6acdeaab /src/lib/corelib/api/jobs.cpp
parentf7973489aef74b1df55f7466cd176e14bbfa76d0 (diff)
Speed up project re-resolving by skipping the loading from file.
When re-resolving an existing project, the build graph already exists in memory and does not have to be read from disk. Change-Id: Icf5cf7396a859d4ee1c495b8cc4fa7a1ee61ff1d Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'src/lib/corelib/api/jobs.cpp')
-rw-r--r--src/lib/corelib/api/jobs.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/lib/corelib/api/jobs.cpp b/src/lib/corelib/api/jobs.cpp
index 7c30c39e2..035a0bf8f 100644
--- a/src/lib/corelib/api/jobs.cpp
+++ b/src/lib/corelib/api/jobs.cpp
@@ -29,7 +29,7 @@
#include "jobs.h"
#include "internaljobs.h"
-#include "project.h"
+#include "project_p.h"
#include <language/language.h>
#include <tools/qbsassert.h>
@@ -187,6 +187,7 @@ void AbstractJob::handleTaskProgress(int newProgressValue)
void AbstractJob::handleFinished()
{
QBS_ASSERT(m_state != StateFinished, return);
+ finish();
m_state = StateFinished;
unlockProject();
emit finished(!error().hasError(), this);
@@ -220,13 +221,19 @@ Project SetupProjectJob::project() const
return Project(job->project(), job->logger());
}
-void SetupProjectJob::resolve(const SetupProjectParameters &parameters)
+void SetupProjectJob::resolve(const Project &existingProject,
+ const SetupProjectParameters &parameters)
{
+ m_existingProject = existingProject;
+ const TopLevelProjectPtr &existingInternalProject
+ = existingProject.d ? existingProject.d->internalProject : TopLevelProjectPtr();
+ if (existingInternalProject && !lockProject(existingInternalProject))
+ return;
InternalJobThreadWrapper * const wrapper
= qobject_cast<InternalJobThreadWrapper *>(internalJob());
InternalSetupProjectJob * const job
= qobject_cast<InternalSetupProjectJob *>(wrapper->synchronousJob());
- job->init(parameters);
+ job->init(existingInternalProject, parameters);
wrapper->start();
}
@@ -239,6 +246,16 @@ void SetupProjectJob::reportError(const ErrorInfo &error)
job->reportError(error);
}
+void SetupProjectJob::finish()
+{
+ // If the new project was successfully created, invalidate the existing one.
+ // The invariant is that there must always be at most one valid Project object
+ // for the same build directory, so that exclusive ownership of the build graph lock
+ // is ensured.
+ if (m_existingProject.isValid() && !error().hasError())
+ m_existingProject.d->internalProject.clear();
+}
+
/*!
* \class ProcessResult
* \brief The \c ProcessResult class represents the result of one external program run by Qbs.