diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2017-12-14 11:00:25 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2017-12-15 09:43:40 +0000 |
commit | f9cf08ce9f202eac83c8d0dc2c1ec68e4d2fcdea (patch) | |
tree | d22eb9eb34ae6b79d61129eeb16d06d687fef745 | |
parent | 193f3f02aae324ba7273e368b528b437da46caac (diff) |
ModuleLoader: Copy id when setting up module instance child items
Problem was uncovered by d08ce8f643, after which the Depends item used
for loading a module is no longer the original one from the prototype
(i.e. the one that got the id assigned by the AST visitor).
Task-number: QBS-1264
Change-Id: Id8bdf0cc903aaabfb3eaafc56445064ed49d1cd7
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
-rw-r--r-- | changelogs/changes-1.10.1.md | 1 | ||||
-rw-r--r-- | src/lib/corelib/language/item.h | 1 | ||||
-rw-r--r-- | src/lib/corelib/language/moduleloader.cpp | 1 | ||||
-rw-r--r-- | tests/auto/language/testdata/idusage.qbs | 5 | ||||
-rw-r--r-- | tests/auto/language/testdata/modules/deepdummy/deep/moat/dummydeepmoat.qbs | 3 | ||||
-rw-r--r-- | tests/auto/language/tst_language.cpp | 6 |
6 files changed, 15 insertions, 2 deletions
diff --git a/changelogs/changes-1.10.1.md b/changelogs/changes-1.10.1.md index e23d39c29..a288a9fe6 100644 --- a/changelogs/changes-1.10.1.md +++ b/changelogs/changes-1.10.1.md @@ -2,4 +2,5 @@ * Fix crash when the "original" value is misused (QBS-1255). * Fix qtquickcompiler support for qml files in subdirectories (QBS-1261). * Fix GCC support for "bare metal" systems (QBS-1263). +* Fix using ids in Depends items (QBS-1264). * Fix race condition when creating Inno Setup, NSIS, or WiX installers. diff --git a/src/lib/corelib/language/item.h b/src/lib/corelib/language/item.h index 62f4adde3..f7004396d 100644 --- a/src/lib/corelib/language/item.h +++ b/src/lib/corelib/language/item.h @@ -129,6 +129,7 @@ public: void setLocation(const CodeLocation &location) { m_location = location; } void setPrototype(Item *prototype) { m_prototype = prototype; } void setFile(const FileContextPtr &file) { m_file = file; } + void setId(const QString &id) { m_id = id; } void setScope(Item *item) { m_scope = item; } void setOuterItem(Item *item) { m_outerItem = item; } void setChildren(const QList<Item *> &children) { m_children = children; } diff --git a/src/lib/corelib/language/moduleloader.cpp b/src/lib/corelib/language/moduleloader.cpp index afdb908ea..4e26362e5 100644 --- a/src/lib/corelib/language/moduleloader.cpp +++ b/src/lib/corelib/language/moduleloader.cpp @@ -2826,6 +2826,7 @@ void ModuleLoader::createChildInstances(Item *instance, Item *prototype, prototypeInstanceMap->insert(childPrototype, childInstance); childInstance->setPrototype(childPrototype); childInstance->setFile(childPrototype->file()); + childInstance->setId(childPrototype->id()); childInstance->setLocation(childPrototype->location()); childInstance->setScope(instance->scope()); Item::addChild(instance, childInstance); diff --git a/tests/auto/language/testdata/idusage.qbs b/tests/auto/language/testdata/idusage.qbs index 6677c3386..c55b47234 100644 --- a/tests/auto/language/testdata/idusage.qbs +++ b/tests/auto/language/testdata/idusage.qbs @@ -22,4 +22,9 @@ Project { nr: product3.nr + 1 name: "product4_" + nr } + + Product { + name: "product5" + Depends { name: "deepdummy.deep.moat" } + } } diff --git a/tests/auto/language/testdata/modules/deepdummy/deep/moat/dummydeepmoat.qbs b/tests/auto/language/testdata/modules/deepdummy/deep/moat/dummydeepmoat.qbs index 3383d69e2..d78a6a553 100644 --- a/tests/auto/language/testdata/modules/deepdummy/deep/moat/dummydeepmoat.qbs +++ b/tests/auto/language/testdata/modules/deepdummy/deep/moat/dummydeepmoat.qbs @@ -1,4 +1,5 @@ Module { property string depth: "abysmal" - Depends { name: "dummy" } + Depends { name: "dummy"; id: dummyId } + property string zort: dummyId.zort } diff --git a/tests/auto/language/tst_language.cpp b/tests/auto/language/tst_language.cpp index c6697b61b..472ae6508 100644 --- a/tests/auto/language/tst_language.cpp +++ b/tests/auto/language/tst_language.cpp @@ -1177,7 +1177,7 @@ void TestLanguage::idUsage() TopLevelProjectPtr project = loader->loadProject(defaultParameters); QVERIFY(!!project); QHash<QString, ResolvedProductPtr> products = productsFromProject(project); - QCOMPARE(products.count(), 4); + QCOMPARE(products.count(), 5); QVERIFY(products.contains("product1_1")); QVERIFY(products.contains("product2_2")); QVERIFY(products.contains("product3_3")); @@ -1185,6 +1185,10 @@ void TestLanguage::idUsage() QVERIFY(!!product4); QEXPECT_FAIL("", "QBS-1016", Continue); QCOMPARE(product4->productProperties.value("productName").toString(), product4->name); + ResolvedProductPtr product5 = products.value("product5"); + QVERIFY(!!product5); + QCOMPARE(product5->moduleProperties->moduleProperty("deepdummy.deep.moat", "zort") + .toString(), QString("zort in dummy")); } catch (const ErrorInfo &e) { exceptionCaught = true; |