diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2018-01-31 09:23:54 +0100 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2018-01-31 13:50:36 +0000 |
commit | 764fd1f6ea3f317ad4b50a865ab56b8a8c93080f (patch) | |
tree | 53aaf9d4ddede25716f043b5666d09260e539f14 | |
parent | 3953e11a8491323bed6d45d3ced59f15b87a96a8 (diff) |
The SOFT ASSERT was triggered, because the Depends items in
Export/Module had the type ModuleInstance instead of ModuleParameters.
Move the assignment of that item type to ItemReaderASTVisitor instead of
adjusting it in the ModuleLoader, because this ensures that we don't
have to traverse prototypes in the adjustment procedure.
Task-number: QBS-1287
Change-Id: Ie1a1080d40b8bebe5c205f8b34298469cde5bd46
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r-- | src/lib/corelib/language/itemreaderastvisitor.cpp | 6 | ||||
-rw-r--r-- | src/lib/corelib/language/itemreaderastvisitor.h | 1 | ||||
-rw-r--r-- | src/lib/corelib/language/moduleloader.cpp | 11 | ||||
-rw-r--r-- | tests/auto/blackbox/tst_blackbox.cpp | 1 |
4 files changed, 11 insertions, 8 deletions
diff --git a/src/lib/corelib/language/itemreaderastvisitor.cpp b/src/lib/corelib/language/itemreaderastvisitor.cpp index 9d77472c2..788539141 100644 --- a/src/lib/corelib/language/itemreaderastvisitor.cpp +++ b/src/lib/corelib/language/itemreaderastvisitor.cpp @@ -117,7 +117,11 @@ bool ItemReaderASTVisitor::visit(AST::UiObjectDefinition *ast) if (ast->initializer) { qSwap(m_item, item); + const ItemType oldInstanceItemType = m_instanceItemType; + if (itemType == ItemType::Parameters || itemType == ItemType::Depends) + m_instanceItemType = ItemType::ModuleParameters; ast->initializer->accept(this); + m_instanceItemType = oldInstanceItemType; qSwap(m_item, item); } @@ -266,7 +270,7 @@ Item *ItemReaderASTVisitor::targetItemForBinding(const QStringList &bindingName, for (int i = 0; i < c; ++i) { ValuePtr v = targetItem->ownProperty(bindingName.at(i)); if (!v) { - const ItemType itemType = i < c - 1 ? ItemType::ModulePrefix : ItemType::ModuleInstance; + const ItemType itemType = i < c - 1 ? ItemType::ModulePrefix : m_instanceItemType; Item *newItem = Item::create(m_itemPool, itemType); newItem->setLocation(value->location()); v = ItemValue::create(newItem); diff --git a/src/lib/corelib/language/itemreaderastvisitor.h b/src/lib/corelib/language/itemreaderastvisitor.h index 5db03b411..6bd39ceb2 100644 --- a/src/lib/corelib/language/itemreaderastvisitor.h +++ b/src/lib/corelib/language/itemreaderastvisitor.h @@ -88,6 +88,7 @@ private: Logger &m_logger; QHash<QStringList, QString> m_typeNameToFile; Item *m_item = nullptr; + ItemType m_instanceItemType = ItemType::ModuleInstance; }; } // namespace Internal diff --git a/src/lib/corelib/language/moduleloader.cpp b/src/lib/corelib/language/moduleloader.cpp index f2dae2cf9..bfb7b8ef1 100644 --- a/src/lib/corelib/language/moduleloader.cpp +++ b/src/lib/corelib/language/moduleloader.cpp @@ -1556,10 +1556,9 @@ static void mergeParameters(QVariantMap &dst, const QVariantMap &src) } } -static void adjustParametersItemTypesAndScopes(Item *item, Item *scope) +static void adjustParametersScopes(Item *item, Item *scope) { - if (item->type() == ItemType::ModuleInstance) { - item->setType(ItemType::ModuleParameters); + if (item->type() == ItemType::ModuleParameters) { item->setScope(scope); return; } @@ -1567,7 +1566,7 @@ static void adjustParametersItemTypesAndScopes(Item *item, Item *scope) for (auto value : item->properties()) { if (value->type() != Value::ItemValueType) continue; - adjustParametersItemTypesAndScopes(std::static_pointer_cast<ItemValue>(value)->item(), scope); + adjustParametersScopes(std::static_pointer_cast<ItemValue>(value)->item(), scope); } } @@ -1609,7 +1608,7 @@ void ModuleLoader::mergeExportItems(const ProductContext &productContext) filesWithExportItem += exportItem->file(); for (Item * const child : exportItem->children()) { if (child->type() == ItemType::Parameters) { - adjustParametersItemTypesAndScopes(child, child); + adjustParametersScopes(child, child); mergeParameters(pmi.defaultParameters, m_evaluator->scriptValue(child).toVariant().toMap()); } else { @@ -2012,7 +2011,7 @@ void ModuleLoader::resolveDependencies(DependsContext *dependsContext, Item *ite for (Item * const dependsItem : dependsItemPerLoadedModule) { if (dependsItem == lastDependsItem) continue; - adjustParametersItemTypesAndScopes(dependsItem, dependsItem); + adjustParametersScopes(dependsItem, dependsItem); forwardParameterDeclarations(dependsItem, loadedModules); lastDependsItem = dependsItem; } diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index c952f2bff..6622c381c 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -2371,7 +2371,6 @@ void TestBlackbox::pluginDependency() QVERIFY(m_qbsStdout.contains("plugin3")); QVERIFY(m_qbsStdout.contains("plugin4")); QVERIFY(m_qbsStdout.contains("helper2")); - QEXPECT_FAIL("", "FIXME", Continue); QVERIFY(!m_qbsStderr.contains("SOFT ASSERT")); // Build the app. Plugins 1 and 2 must not be linked. Plugin 3 must be linked. |