aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2017-10-04 11:59:05 +0200
committerJoerg Bornemann <joerg.bornemann@qt.io>2017-10-04 14:11:37 +0000
commit6d568728aceb0beda1545706fe70450333410c86 (patch)
tree8412b3f3a507e105368c72845166fb286a95c03d
parent0b46440f5310018b5e881b03a355953bdb2ea188 (diff)
Fix usage of outer within Properties blocks
In EvaluatorScriptClass we're cloning the value that's referenced by "outer" and leave out the list of alternatives. This custom cloning code was missing the defining item of JSSourceValue, which led to an error if the outer item was dependent on some other property. Now, we create a full clone and clear the necessary members. This ensures we do not have to adjust this code if another member is added to JSSourceValue. Task-number: QBS-1205 Change-Id: I59596894f365fa5207490922ee60959e221102b1 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rwxr-xr-xsrc/lib/corelib/language/evaluatorscriptclass.cpp13
-rw-r--r--src/lib/corelib/language/value.cpp5
-rw-r--r--src/lib/corelib/language/value.h4
-rw-r--r--tests/auto/language/testdata/propertiesblocks.qbs20
-rw-r--r--tests/auto/language/tst_language.cpp8
5 files changed, 41 insertions, 9 deletions
diff --git a/src/lib/corelib/language/evaluatorscriptclass.cpp b/src/lib/corelib/language/evaluatorscriptclass.cpp
index ba7df02b5..d75408a36 100755
--- a/src/lib/corelib/language/evaluatorscriptclass.cpp
+++ b/src/lib/corelib/language/evaluatorscriptclass.cpp
@@ -215,14 +215,11 @@ private:
// condition is true, let's use the value of this alternative
if (alternative->value->sourceUsesOuter() && !outerItem) {
// Clone value but without alternatives.
- JSSourceValuePtr outerValue = JSSourceValue::create();
- outerValue->setFile(value->file());
- outerValue->setHasFunctionForm(value->hasFunctionForm());
- outerValue->setSourceCode(value->sourceCode());
- outerValue->setBaseValue(value->baseValue());
- if (value->sourceUsesBase())
- outerValue->setSourceUsesBaseFlag();
- outerValue->setLocation(value->line(), value->column());
+ JSSourceValuePtr outerValue =
+ std::static_pointer_cast<JSSourceValue>(value->clone());
+ outerValue->setNext(ValuePtr());
+ outerValue->clearCreatedByPropertiesBlock();
+ outerValue->clearAlternatives();
outerItem = Item::create(data->item->pool(), ItemType::Outer);
outerItem->setProperty(propertyName->toString(), outerValue);
}
diff --git a/src/lib/corelib/language/value.cpp b/src/lib/corelib/language/value.cpp
index 1b73ccf17..f6d06ef83 100644
--- a/src/lib/corelib/language/value.cpp
+++ b/src/lib/corelib/language/value.cpp
@@ -152,6 +152,11 @@ void JSSourceValue::setHasFunctionForm(bool b)
m_flags &= ~HasFunctionForm;
}
+void JSSourceValue::clearAlternatives()
+{
+ m_alternatives.clear();
+}
+
void JSSourceValue::setDefiningItem(Item *item)
{
Value::setDefiningItem(item);
diff --git a/src/lib/corelib/language/value.h b/src/lib/corelib/language/value.h
index 6b0c98dc9..f0b4c44a6 100644
--- a/src/lib/corelib/language/value.h
+++ b/src/lib/corelib/language/value.h
@@ -75,12 +75,13 @@ public:
void setNext(const ValuePtr &next);
bool createdByPropertiesBlock() const { return m_createdByPropertiesBlock; }
+ void clearCreatedByPropertiesBlock() { m_createdByPropertiesBlock = false; }
private:
Type m_type;
Item *m_definingItem;
ValuePtr m_next;
- const bool m_createdByPropertiesBlock;
+ bool m_createdByPropertiesBlock;
};
class ValueHandler
@@ -158,6 +159,7 @@ public:
const QList<Alternative> &alternatives() const { return m_alternatives; }
void setAlternatives(const QList<Alternative> &alternatives) { m_alternatives = alternatives; }
void addAlternative(const Alternative &alternative) { m_alternatives.append(alternative); }
+ void clearAlternatives();
void setDefiningItem(Item *item);
diff --git a/tests/auto/language/testdata/propertiesblocks.qbs b/tests/auto/language/testdata/propertiesblocks.qbs
index 48a801bd8..8566166d9 100644
--- a/tests/auto/language/testdata/propertiesblocks.qbs
+++ b/tests/auto/language/testdata/propertiesblocks.qbs
@@ -37,6 +37,26 @@ Project {
}
}
Product {
+ name: "property_append_to_indirect_outer"
+ Depends { name: "dummy" }
+ property stringList myDefines: ["ONE"]
+ dummy.defines: myDefines
+ Properties {
+ condition: true
+ dummy.defines: outer.concat(["TWO"])
+ }
+ }
+ Product {
+ name: "property_append_to_indirect_merged_outer"
+ Depends { name: "dummy" }
+ property string justOne: "ONE"
+ dummy.rpaths: [justOne]
+ Properties {
+ condition: true
+ dummy.rpaths: outer.concat(["TWO"])
+ }
+ }
+ Product {
name: "multiple_exclusive_properties"
Depends { name: "dummy" }
dummy.defines: ["SOMETHING"]
diff --git a/tests/auto/language/tst_language.cpp b/tests/auto/language/tst_language.cpp
index 19c67eda3..c4016323b 100644
--- a/tests/auto/language/tst_language.cpp
+++ b/tests/auto/language/tst_language.cpp
@@ -1988,6 +1988,14 @@ void TestLanguage::propertiesBlocks_data()
<< QString("dummy.defines")
<< (QStringList() << QString("ONE") << QString("TWO"))
<< QString();
+ QTest::newRow("property_append_to_indirect_outer")
+ << QString("dummy.defines")
+ << (QStringList() << QString("ONE") << QString("TWO"))
+ << QString();
+ QTest::newRow("property_append_to_indirect_merged_outer")
+ << QString("dummy.rpaths")
+ << (QStringList() << QString("ONE") << QString("TWO") << QString("$ORIGIN"))
+ << QString();
QTest::newRow("multiple_exclusive_properties")
<< QString("dummy.defines")