summaryrefslogtreecommitdiff
path: root/src/lib/buildgraph
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@digia.com>2013-07-23 09:48:36 +0200
committerChristian Kandeler <christian.kandeler@digia.com>2013-07-23 12:40:17 +0200
commit81b9c927208215d14715f66fbf8e266dd442c727 (patch)
tree3a99f343827ac741e4b4f9df508fed9681551bbf /src/lib/buildgraph
parent617d1f73cf69b96e467e31bcc8a864b9184ebdae (diff)
downloadqbs-81b9c927208215d14715f66fbf8e266dd442c727.tar.gz
simplify JS command execution
Do not modify the global object. Use pushScope/popScope instead of pushContext/popContext. Remove a futile caching attempt. Change-Id: I2c7440356db13db25c1770e9461ef6247d1bb7dc Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
Diffstat (limited to 'src/lib/buildgraph')
-rw-r--r--src/lib/buildgraph/jscommandexecutor.cpp29
1 files changed, 11 insertions, 18 deletions
diff --git a/src/lib/buildgraph/jscommandexecutor.cpp b/src/lib/buildgraph/jscommandexecutor.cpp
index 45815a104..a7f104aea 100644
--- a/src/lib/buildgraph/jscommandexecutor.cpp
+++ b/src/lib/buildgraph/jscommandexecutor.cpp
@@ -78,28 +78,23 @@ public slots:
m_result.success = true;
m_result.errorMessage.clear();
ScriptEngine * const scriptEngine = provideScriptEngine();
- QString trafoPtrStr = QString::number((qulonglong)transformer);
- if (scriptEngine->globalObject().property("_qbs_transformer_ptr").toString() != trafoPtrStr) {
- scriptEngine->globalObject().setProperty("_qbs_transformer_ptr", scriptEngine->toScriptValue(trafoPtrStr));
-
- Artifact *someOutputArtifact = *transformer->outputs.begin();
- const ResolvedProductConstPtr product = someOutputArtifact->product.toStrongRef();
- if (product) {
- setupScriptEngineForProduct(scriptEngine, product, transformer->rule,
- scriptEngine->globalObject());
- }
- transformer->setupInputs(scriptEngine, scriptEngine->globalObject());
- transformer->setupOutputs(scriptEngine, scriptEngine->globalObject());
- }
+ QScriptValue scope = scriptEngine->newObject();
+ Artifact *someOutputArtifact = *transformer->outputs.begin();
+ if (!someOutputArtifact->product.isNull())
+ setupScriptEngineForProduct(scriptEngine, someOutputArtifact->product,
+ transformer->rule, scope);
+ transformer->setupInputs(scriptEngine, scope);
+ transformer->setupOutputs(scriptEngine, scope);
- scriptEngine->pushContext();
for (QVariantMap::const_iterator it = cmd->properties().constBegin();
it != cmd->properties().constEnd(); ++it) {
- scriptEngine->currentContext()->activationObject().setProperty(it.key(),
- scriptEngine->toScriptValue(it.value()));
+ scope.setProperty(it.key(), scriptEngine->toScriptValue(it.value()));
}
+ QScriptContext *ctx = scriptEngine->currentContext();
+ ctx->pushScope(scope);
scriptEngine->evaluate(cmd->sourceCode());
+ ctx->popScope();
if (scriptEngine->hasUncaughtException()) {
m_result.success = false;
m_result.errorMessage = scriptEngine->uncaughtException().toString();
@@ -108,8 +103,6 @@ public slots:
origLocation.line() + scriptEngine->uncaughtExceptionLineNumber(),
origLocation.column());
}
- scriptEngine->popContext();
- scriptEngine->clearExceptions();
emit finished();
}