diff options
author | Christian Kandeler <christian.kandeler@theqtcompany.com> | 2015-10-02 10:00:33 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@theqtcompany.com> | 2015-10-02 13:13:10 +0000 |
commit | 55ff3783ce27c87517ae4758fdaca0f16a86367b (patch) | |
tree | 68f9b1a000e8ccec858686ce1f6874ab3aaa493a | |
parent | 9087e2667e20a391acd9caa34293e913cee19080 (diff) |
Fix using Properties items in Groups.v1.4.3
In EvaluatorScriptClass, we overwrote the already existing outer item
with a (non-working) new one. The original intention of that code is not
entirely clear to me; my assumption is that it can continue to exist as
a fallback where "outer" is used outside a group.
Task-number: QBS-877
Change-Id: Ife0b7f85574f7d880307cd2f65f551a64ca3cf6f
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
-rw-r--r-- | src/lib/corelib/language/evaluatorscriptclass.cpp | 4 | ||||
-rw-r--r-- | src/lib/corelib/language/testdata/dummy.txt | 0 | ||||
-rw-r--r-- | src/lib/corelib/language/testdata/properties-block-in-group.qbs | 16 | ||||
-rw-r--r-- | src/lib/corelib/language/tst_language.cpp | 25 | ||||
-rw-r--r-- | src/lib/corelib/language/tst_language.h | 1 |
5 files changed, 45 insertions, 1 deletions
diff --git a/src/lib/corelib/language/evaluatorscriptclass.cpp b/src/lib/corelib/language/evaluatorscriptclass.cpp index 9ebd2e077..48c66606a 100644 --- a/src/lib/corelib/language/evaluatorscriptclass.cpp +++ b/src/lib/corelib/language/evaluatorscriptclass.cpp @@ -186,13 +186,15 @@ private: } if (cr.toBool()) { // condition is true, let's use the value of this alternative - if (alternative->value->sourceUsesOuter()) { + 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()); outerItem = Item::create(data->item->pool()); outerItem->setProperty(propertyName->toString(), outerValue); diff --git a/src/lib/corelib/language/testdata/dummy.txt b/src/lib/corelib/language/testdata/dummy.txt new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/lib/corelib/language/testdata/dummy.txt diff --git a/src/lib/corelib/language/testdata/properties-block-in-group.qbs b/src/lib/corelib/language/testdata/properties-block-in-group.qbs new file mode 100644 index 000000000..c2bfea0a8 --- /dev/null +++ b/src/lib/corelib/language/testdata/properties-block-in-group.qbs @@ -0,0 +1,16 @@ +import qbs + +Product { + name: "in-group" + property bool featureEnabled: true + Depends { name: "dummy" } + dummy.defines: ["BASEDEF"] + Group { + name: "the group" + files: ["dummy.txt" ] + Properties { + condition: featureEnabled + dummy.defines: outer.concat("FEATURE_ENABLED") + } + } +} diff --git a/src/lib/corelib/language/tst_language.cpp b/src/lib/corelib/language/tst_language.cpp index 8d0d09f3a..c3cb0560e 100644 --- a/src/lib/corelib/language/tst_language.cpp +++ b/src/lib/corelib/language/tst_language.cpp @@ -1424,6 +1424,31 @@ void TestLanguage::propertiesBlocks() } } +void TestLanguage::propertiesBlockInGroup() +{ + bool exceptionCaught = false; + try { + defaultParameters.setProjectFilePath(testProject("properties-block-in-group.qbs")); + const TopLevelProjectPtr project = loader->loadProject(defaultParameters); + QVERIFY(project); + QCOMPARE(project->allProducts().count(), 1); + const ResolvedProductConstPtr product = project->allProducts().first(); + const auto groupIt = std::find_if(product->groups.constBegin(), product->groups.constEnd(), + [](const GroupConstPtr &g) { return g->name == "the group"; }); + QVERIFY(groupIt != product->groups.constEnd()); + const QVariantMap propertyMap = (*groupIt)->properties->value(); + const QVariantList value = PropertyFinder().propertyValues(propertyMap, "dummy", "defines"); + QStringList stringListValue; + std::transform(value.constBegin(), value.constEnd(), std::back_inserter(stringListValue), + [](const QVariant &v) { return v.toString(); }); + QCOMPARE(stringListValue, QStringList() << "BASEDEF" << "FEATURE_ENABLED"); + } catch (const ErrorInfo &e) { + exceptionCaught = true; + qDebug() << e.toString(); + } + QCOMPARE(exceptionCaught, false); +} + void TestLanguage::qbsPropertiesInProjectCondition() { bool exceptionCaught = false; diff --git a/src/lib/corelib/language/tst_language.h b/src/lib/corelib/language/tst_language.h index 4442c5a73..6d4bfee99 100644 --- a/src/lib/corelib/language/tst_language.h +++ b/src/lib/corelib/language/tst_language.h @@ -106,6 +106,7 @@ private slots: void profileValuesAndOverriddenValues(); void propertiesBlocks_data(); void propertiesBlocks(); + void propertiesBlockInGroup(); void qbsPropertiesInProjectCondition(); void defaultValue(); void defaultValue_data(); |