summaryrefslogtreecommitdiff
path: root/src/lib/buildgraph
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@digia.com>2013-07-24 10:10:28 +0200
committerChristian Kandeler <christian.kandeler@digia.com>2013-07-24 10:53:28 +0200
commit68acfeeb77973b8329441929d90237e704efbd1d (patch)
treeb85217f6f249378836790a5109c9376dbb2c6dee /src/lib/buildgraph
parent386d329e5df8a644a8bcfa2eed193a0dbad4f5bd (diff)
downloadqbs-68acfeeb77973b8329441929d90237e704efbd1d.tar.gz
fix caching of observer, project and product
We stored the cache key in the engine and the cache value in the target object of setupScriptEngineForProduct. This was a result of the "don't use the global object" refactoring. Change-Id: Id6796bf60927d14b8968cbb3760d9ca2bcbb7933 Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
Diffstat (limited to 'src/lib/buildgraph')
-rw-r--r--src/lib/buildgraph/buildgraph.cpp52
1 files changed, 20 insertions, 32 deletions
diff --git a/src/lib/buildgraph/buildgraph.cpp b/src/lib/buildgraph/buildgraph.cpp
index efb210568..2113da2f6 100644
--- a/src/lib/buildgraph/buildgraph.cpp
+++ b/src/lib/buildgraph/buildgraph.cpp
@@ -164,53 +164,41 @@ void setupScriptEngineForProduct(ScriptEngine *engine, const ResolvedProductCons
const RuleConstPtr &rule, QScriptValue targetObject,
ScriptPropertyObserver *observer)
{
- ScriptPropertyObserver *lastObserver = reinterpret_cast<ScriptPropertyObserver *>(
- engine->property("lastObserver").toULongLong());
- const ResolvedProject *lastSetupProject = 0;
- const ResolvedProduct *lastSetupProduct = 0;
- if (lastObserver == observer) {
- lastSetupProject = reinterpret_cast<ResolvedProject *>(
- engine->property("lastSetupProject").toULongLong());
- lastSetupProduct = reinterpret_cast<ResolvedProduct *>(
- engine->property("lastSetupProduct").toULongLong());
- } else {
- engine->setProperty("lastObserver", QVariant(reinterpret_cast<qulonglong>(observer)));
+ ScriptEngine::ScriptValueCache * const cache = engine->scriptValueCache();
+ if (cache->observer != observer) {
+ cache->project = 0;
+ cache->product = 0;
}
- if (lastSetupProject != product->project) {
- engine->setProperty("lastSetupProject",
- QVariant(reinterpret_cast<qulonglong>(product->project.data())));
- QScriptValue projectScriptValue;
- projectScriptValue = engine->newObject();
- projectScriptValue.setProperty("filePath", product->project->location.fileName());
- projectScriptValue.setProperty("path",
- FileInfo::path(product->project->location.fileName()));
+ if (cache->project != product->project) {
+ cache->project = product->project.data();
+ cache->projectScriptValue = engine->newObject();
+ cache->projectScriptValue.setProperty(QLatin1String("filePath"),
+ product->project->location.fileName());
+ cache->projectScriptValue.setProperty(QLatin1String("path"),
+ FileInfo::path(product->project->location.fileName()));
const QVariantMap &projectProperties = product->project->projectProperties();
for (QVariantMap::const_iterator it = projectProperties.begin();
it != projectProperties.end(); ++it)
- projectScriptValue.setProperty(it.key(), engine->toScriptValue(it.value()));
- targetObject.setProperty("project", projectScriptValue);
+ cache->projectScriptValue.setProperty(it.key(), engine->toScriptValue(it.value()));
}
+ targetObject.setProperty(QLatin1String("project"), cache->projectScriptValue);
- QScriptValue productScriptValue;
- if (lastSetupProduct != product.data()) {
- engine->setProperty("lastSetupProduct",
- QVariant(reinterpret_cast<qulonglong>(product.data())));
+ if (cache->product != product) {
+ cache->product = product.data();
{
QVariant v;
v.setValue<void*>(&product->buildEnvironment);
engine->setProperty("_qbs_procenv", v);
}
- productScriptValue = engine->newObject();
- setupProductScriptValue(engine, productScriptValue, product, observer);
- targetObject.setProperty("product", productScriptValue);
- } else {
- productScriptValue = targetObject.property("product");
+ cache->productScriptValue = engine->newObject();
+ setupProductScriptValue(engine, cache->productScriptValue, product, observer);
}
+ targetObject.setProperty(QLatin1String("product"), cache->productScriptValue);
// If the Rule is in a Module, set up the 'moduleName' property
- if (!rule->module->name.isEmpty())
- productScriptValue.setProperty(QLatin1String("moduleName"), rule->module->name);
+ cache->productScriptValue.setProperty(QLatin1String("moduleName"),
+ rule->module->name.isEmpty() ? QScriptValue() : rule->module->name);
engine->import(rule->jsImports, targetObject, targetObject);
JsExtensions::setupExtensions(rule->jsExtensions, targetObject);