aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@digia.com>2012-11-23 14:49:35 +0100
committerChristian Kandeler <christian.kandeler@digia.com>2012-11-23 17:45:17 +0100
commit904dd8fe77721a51303b02a413f52303141b3a01 (patch)
tree9711645877d80ebb912bb284d330f11b1b994a72
parente2422bbfdaccbad35acf3e6c4252ab67f121f97e (diff)
Make Ctrl-C more responsive.
Check for cancelation in the loading stage and while applying rules. Change-Id: Ic192a74017e0d263b8e8f6d2d6fbb8443a09ce68 Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
-rw-r--r--src/lib/buildgraph/buildgraph.cpp16
-rw-r--r--src/lib/buildgraph/buildgraph.h2
-rw-r--r--src/lib/language/loader.cpp12
3 files changed, 26 insertions, 4 deletions
diff --git a/src/lib/buildgraph/buildgraph.cpp b/src/lib/buildgraph/buildgraph.cpp
index d2789c6ad..b0a444430 100644
--- a/src/lib/buildgraph/buildgraph.cpp
+++ b/src/lib/buildgraph/buildgraph.cpp
@@ -236,6 +236,17 @@ void BuildGraph::setProgressObserver(ProgressObserver *observer)
m_progressObserver = observer;
}
+const ProgressObserver *BuildGraph::progressObserver() const
+{
+ return m_progressObserver;
+}
+
+void BuildGraph::checkCancelation() const
+{
+ if (m_progressObserver && m_progressObserver->canceled())
+ throw Error(Tr::tr("Build canceled."));
+}
+
bool BuildGraph::findPath(Artifact *u, Artifact *v, QList<Artifact*> &path)
{
@@ -500,8 +511,7 @@ BuildProduct::Ptr BuildGraph::resolveProduct(const BuildProject::Ptr &project,
return product;
if (m_progressObserver) {
- if (m_progressObserver->canceled())
- throw Error(Tr::tr("Build canceled."));
+ checkCancelation();
m_progressObserver->incrementProgressValue();
}
@@ -1238,6 +1248,8 @@ void RulesApplicator::applyRule(const Rule::ConstPtr &rule)
void RulesApplicator::doApply(const ArtifactList &inputArtifacts)
{
+ m_buildGraph->checkCancelation();
+
if (qbsLogLevel(LoggerDebug))
qbsDebug() << "[BG] apply rule " << m_rule->toString() << " " << toStringList(inputArtifacts).join(",\n ");
diff --git a/src/lib/buildgraph/buildgraph.h b/src/lib/buildgraph/buildgraph.h
index 28c1d9ca6..652a06a9b 100644
--- a/src/lib/buildgraph/buildgraph.h
+++ b/src/lib/buildgraph/buildgraph.h
@@ -163,6 +163,8 @@ public:
void applyRules(BuildProduct *product, ArtifactsPerFileTagMap &artifactsPerFileTag);
void setProgressObserver(ProgressObserver *observer);
+ const ProgressObserver *progressObserver() const;
+ void checkCancelation() const;
static bool findPath(Artifact *u, Artifact *v, QList<Artifact*> &path);
static void connect(Artifact *p, Artifact *c);
diff --git a/src/lib/language/loader.cpp b/src/lib/language/loader.cpp
index 5ac2ce3c2..31bf5d9e8 100644
--- a/src/lib/language/loader.cpp
+++ b/src/lib/language/loader.cpp
@@ -400,6 +400,7 @@ public:
const QVariantMap &userProperties);
ProjectFile::Ptr parseFile(const QString &fileName);
+ void checkCancelation() const;
void clearScopesCache();
Scope::Ptr buildFileContext(ProjectFile *file);
bool existsModuleInSearchPath(const QString &moduleName);
@@ -1822,6 +1823,7 @@ static QString sourceDirPath(const Property &property, const ResolvedProduct::Co
QVariantMap Loader::LoaderPrivate::evaluateAll(const ResolvedProduct::ConstPtr &rproduct,
const Scope::Ptr &properties)
{
+ checkCancelation();
QVariantMap &result = m_convertedScopesCache[properties];
if (!result.isEmpty())
return result;
@@ -1906,6 +1908,7 @@ Module::Ptr Loader::LoaderPrivate::loadModule(ProjectFile *file, const QStringLi
ScopeChain::Ptr moduleBaseScope, const QVariantMap &userProperties,
const CodeLocation &dependsLocation)
{
+ checkCancelation();
const bool isBaseModule = (moduleName == "qbs");
Module::Ptr module = Module::Ptr(new Module);
@@ -2369,8 +2372,7 @@ ResolvedProject::Ptr Loader::LoaderPrivate::resolveProject(const QString &buildR
m_progressObserver->initialize(Tr::tr("Loading project"), projectData.products.count());
for (; it != projectData.products.end(); ++it) {
if (m_progressObserver) {
- if (m_progressObserver->canceled())
- throw Error(Tr::tr("Loading canceled."));
+ checkCancelation();
m_progressObserver->incrementProgressValue();
}
resolveProduct(it.key(), rproject, it.value(), resolvedProducts, globalRules,
@@ -3053,6 +3055,12 @@ ProjectFile::Ptr Loader::LoaderPrivate::parseFile(const QString &fileName)
return result;
}
+void Loader::LoaderPrivate::checkCancelation() const
+{
+ if (m_progressObserver && m_progressObserver->canceled())
+ throw Error(Tr::tr("Loading canceled."));
+}
+
Loader::LoaderPrivate *Loader::LoaderPrivate::get(QScriptEngine *engine)
{
QVariant v = engine->property(szLoaderPropertyName);