aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2017-07-04 11:59:19 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2017-07-04 11:04:23 +0000
commit75492633081511644d263b8a6e4ff494f78dc4bc (patch)
tree5d68d19124d83efba9351f97c375ae2b40688b96
parentea3a1191a5b89b8fe927409f3914eacd8bd748e5 (diff)
Fix false positive in property declaration checker
During export item merging, we lost the information about whether the property was setup by a Properties block. Change-Id: I899188b10aea66dfcfdb61e348d93be1f69347a3 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
-rw-r--r--src/lib/corelib/language/item.cpp28
-rw-r--r--src/lib/corelib/language/item.h4
-rwxr-xr-xsrc/lib/corelib/language/moduleloader.cpp5
-rw-r--r--tests/auto/language/testdata/exports.qbs13
-rw-r--r--tests/auto/language/tst_language.cpp10
5 files changed, 49 insertions, 11 deletions
diff --git a/src/lib/corelib/language/item.cpp b/src/lib/corelib/language/item.cpp
index e02fa08c3..26a08ace0 100644
--- a/src/lib/corelib/language/item.cpp
+++ b/src/lib/corelib/language/item.cpp
@@ -149,14 +149,26 @@ ValuePtr Item::ownProperty(const QString &name) const
ItemValuePtr Item::itemProperty(const QString &name, const Item *itemTemplate)
{
- ItemValuePtr result;
- ValuePtr v = property(name);
- if (v && v->type() == Value::ItemValueType) {
- result = std::static_pointer_cast<ItemValue>(v);
- } else if (itemTemplate) {
- result = ItemValue::create(Item::create(m_pool, itemTemplate->type()));
- setProperty(name, result);
- }
+ return itemProperty(name, itemTemplate, ItemValueConstPtr());
+}
+
+ItemValuePtr Item::itemProperty(const QString &name, const ItemValueConstPtr &value)
+{
+ return itemProperty(name, value->item(), value);
+}
+
+ItemValuePtr Item::itemProperty(const QString &name, const Item *itemTemplate,
+ const ItemValueConstPtr &itemValue)
+{
+ const ValuePtr v = property(name);
+ if (v && v->type() == Value::ItemValueType)
+ return std::static_pointer_cast<ItemValue>(v);
+ if (!itemTemplate)
+ return ItemValuePtr();
+ const bool createdByPropertiesBlock = itemValue && itemValue->createdByPropertiesBlock();
+ const ItemValuePtr result = ItemValue::create(Item::create(m_pool, itemTemplate->type()),
+ createdByPropertiesBlock);
+ setProperty(name, result);
return result;
}
diff --git a/src/lib/corelib/language/item.h b/src/lib/corelib/language/item.h
index 3df4c5903..f2ca71aac 100644
--- a/src/lib/corelib/language/item.h
+++ b/src/lib/corelib/language/item.h
@@ -116,6 +116,7 @@ public:
ValuePtr property(const QString &name) const;
ValuePtr ownProperty(const QString &name) const;
ItemValuePtr itemProperty(const QString &name, const Item *itemTemplate = nullptr);
+ ItemValuePtr itemProperty(const QString &name, const ItemValueConstPtr &value);
JSSourceValuePtr sourceProperty(const QString &name) const;
VariantValuePtr variantProperty(const QString &name) const;
void setObserver(ItemObserver *observer) const;
@@ -138,6 +139,9 @@ public:
void copyProperty(const QString &propertyName, Item *target) const;
private:
+ ItemValuePtr itemProperty(const QString &name, const Item *itemTemplate,
+ const ItemValueConstPtr &itemValue);
+
void dump(int indentation) const;
ItemPool *m_pool;
diff --git a/src/lib/corelib/language/moduleloader.cpp b/src/lib/corelib/language/moduleloader.cpp
index 9d9e8c6cc..6566b606b 100755
--- a/src/lib/corelib/language/moduleloader.cpp
+++ b/src/lib/corelib/language/moduleloader.cpp
@@ -1399,8 +1399,9 @@ void ModuleLoader::handlePropertyOptions(Item *optionsItem)
static void mergeProperty(Item *dst, const QString &name, const ValuePtr &value)
{
if (value->type() == Value::ItemValueType) {
- Item *valueItem = std::static_pointer_cast<ItemValue>(value)->item();
- Item *subItem = dst->itemProperty(name, valueItem)->item();
+ const ItemValueConstPtr itemValue = std::static_pointer_cast<ItemValue>(value);
+ const Item * const valueItem = itemValue->item();
+ Item * const subItem = dst->itemProperty(name, itemValue)->item();
for (QMap<QString, ValuePtr>::const_iterator it = valueItem->properties().constBegin();
it != valueItem->properties().constEnd(); ++it)
mergeProperty(subItem, it.key(), it.value());
diff --git a/tests/auto/language/testdata/exports.qbs b/tests/auto/language/testdata/exports.qbs
index c480f0097..4c3a472c6 100644
--- a/tests/auto/language/testdata/exports.qbs
+++ b/tests/auto/language/testdata/exports.qbs
@@ -102,4 +102,17 @@ Project {
qbs.install: false
}
}
+
+ Product {
+ name: "dependency"
+ Export {
+ property bool depend: false
+ Depends { condition: depend; name: "cpp" }
+ Properties { condition: depend; cpp.includePaths: ["."] }
+ }
+ }
+ Product {
+ name: "depender"
+ Depends { name: "dependency" }
+ }
}
diff --git a/tests/auto/language/tst_language.cpp b/tests/auto/language/tst_language.cpp
index 702621871..0c6be2902 100644
--- a/tests/auto/language/tst_language.cpp
+++ b/tests/auto/language/tst_language.cpp
@@ -726,7 +726,7 @@ void TestLanguage::exports()
TopLevelProjectPtr project = loader->loadProject(defaultParameters);
QVERIFY(!!project);
QHash<QString, ResolvedProductPtr> products = productsFromProject(project);
- QCOMPARE(products.count(), 17);
+ QCOMPARE(products.count(), 19);
ResolvedProductPtr product;
product = products.value("myapp");
QVERIFY(!!product);
@@ -812,6 +812,14 @@ void TestLanguage::exports()
propertyName = QStringList() << "modules" << "dummy" << "productName";
propertyValue = product->moduleProperties->property(propertyName);
QCOMPARE(propertyValue.toString(), QString("libE"));
+
+ product = products.value("depender");
+ QVERIFY(!!product);
+ QCOMPARE(product->modules.count(), 2);
+ for (const ResolvedModuleConstPtr &m : qAsConst(product->modules)) {
+ QVERIFY2(m->name == QString("qbs") || m->name == QString("dependency"),
+ qPrintable(m->name));
+ }
}
catch (const ErrorInfo &e) {
exceptionCaught = true;