aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/corelib/language/evaluatorscriptclass.cpp
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2017-06-01 14:16:29 +0200
committerJoerg Bornemann <joerg.bornemann@qt.io>2017-06-02 18:31:26 +0000
commit438c774acf103055612022dfe4f6f2a5bbcd2899 (patch)
tree966f30537aa2461a4eb32c20403aa78d0f65b952 /src/lib/corelib/language/evaluatorscriptclass.cpp
parente77b0a737b832e5677e37a34eedca586bb36647b (diff)
Fix lookup of shadowed parent properties
Consider the following example Project { name: "project" property string projectName: name Product { name: "product" property string foo: projectName } } The foo property is supposed to have the value "project". Instead it had the value "product". EvaluatorScriptClass::property() and SVConverter assume that data->item is the item that's attached to the QScriptValue object. That was not the case when a property was automatically looked up in the parent item. Task-number: QBS-1117 Change-Id: I21d4cc4106ae631730cd34fe352459d311b09501 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/lib/corelib/language/evaluatorscriptclass.cpp')
-rw-r--r--src/lib/corelib/language/evaluatorscriptclass.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/lib/corelib/language/evaluatorscriptclass.cpp b/src/lib/corelib/language/evaluatorscriptclass.cpp
index c68a195bc..e42345094 100644
--- a/src/lib/corelib/language/evaluatorscriptclass.cpp
+++ b/src/lib/corelib/language/evaluatorscriptclass.cpp
@@ -376,6 +376,7 @@ QScriptClass::QueryFlags EvaluatorScriptClass::queryItemProperty(const Evaluatio
parentdata.item = data->item->parent();
const QueryFlags qf = queryItemProperty(&parentdata, name, true);
if (qf.testFlag(HandlesReadAccess)) {
+ m_queryResult.foundInParent = true;
m_queryResult.data = data;
return qf;
}
@@ -575,8 +576,10 @@ private:
QScriptValue EvaluatorScriptClass::property(const QScriptValue &object, const QScriptString &name,
uint id)
{
+ const bool foundInParent = m_queryResult.foundInParent;
const EvaluationData *data = m_queryResult.data;
const Item * const itemOfProperty = m_queryResult.itemOfProperty;
+ m_queryResult.foundInParent = false;
m_queryResult.data = 0;
m_queryResult.itemOfProperty = 0;
QBS_ASSERT(data, return QScriptValue());
@@ -612,7 +615,11 @@ QScriptValue EvaluatorScriptClass::property(const QScriptValue &object, const QS
if (value->next() && !m_currentNextChain.contains(value.data())) {
collectValuesFromNextChain(data, &result, name.toString(), value);
} else {
- SVConverter converter(this, &object, value, itemOfProperty, &name, data, &result);
+ QScriptValue parentObject;
+ if (foundInParent)
+ parentObject = data->evaluator->scriptValue(data->item->parent());
+ SVConverter converter(this, foundInParent ? &parentObject : &object, value, itemOfProperty,
+ &name, data, &result);
converter.start();
const PropertyDeclaration decl = data->item->propertyDeclaration(name.toString());