aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/corelib/language
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@theqtcompany.com>2015-01-19 12:26:19 +0100
committerChristian Kandeler <christian.kandeler@theqtcompany.com>2015-01-19 14:01:19 +0100
commit6fdf405ad7105e93f5de38a396c4b3f206a2a0ca (patch)
tree081011cdc043cf8807687d396d0c9e1bfb7fd908 /src/lib/corelib/language
parent27952cfe8b348e70cfe98379f0542c082c0f019b (diff)
Fix project parse error.
Access to qbs properties was magically available even before loading the qbs module (for reasons beyond my knowledge), but this only worked when no qbs properties were set in the product. Task-number: QBS-728 Change-Id: If4323d4bd390d561b788538af7e69fca042a7f02 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Diffstat (limited to 'src/lib/corelib/language')
-rw-r--r--src/lib/corelib/language/item.cpp5
-rw-r--r--src/lib/corelib/language/item.h1
-rw-r--r--src/lib/corelib/language/moduleloader.cpp26
-rw-r--r--src/lib/corelib/language/moduleloader.h2
4 files changed, 30 insertions, 4 deletions
diff --git a/src/lib/corelib/language/item.cpp b/src/lib/corelib/language/item.cpp
index 0171658f3..f30aa6814 100644
--- a/src/lib/corelib/language/item.cpp
+++ b/src/lib/corelib/language/item.cpp
@@ -155,6 +155,11 @@ void Item::setPropertyObserver(ItemObserver *observer) const
m_propertyObserver = observer;
}
+void Item::removeProperty(const QString &name)
+{
+ m_properties.remove(name);
+}
+
Item *Item::child(const QString &type, bool checkForMultiple) const
{
Item *child = 0;
diff --git a/src/lib/corelib/language/item.h b/src/lib/corelib/language/item.h
index 744cf42a1..385bd7582 100644
--- a/src/lib/corelib/language/item.h
+++ b/src/lib/corelib/language/item.h
@@ -104,6 +104,7 @@ public:
VariantValuePtr variantProperty(const QString &name) const;
void setPropertyObserver(ItemObserver *observer) const;
void setProperty(const QString &name, const ValuePtr &value);
+ void removeProperty(const QString &name);
void setPropertyDeclaration(const QString &name, const PropertyDeclaration &declaration);
void setTypeName(const QString &name);
void setLocation(const CodeLocation &location);
diff --git a/src/lib/corelib/language/moduleloader.cpp b/src/lib/corelib/language/moduleloader.cpp
index 807a1f8cd..b9b5345d7 100644
--- a/src/lib/corelib/language/moduleloader.cpp
+++ b/src/lib/corelib/language/moduleloader.cpp
@@ -254,8 +254,10 @@ void ModuleLoader::handleProject(ModuleLoaderResult *loadResult, Item *item,
foreach (Item *child, item->children()) {
child->setScope(projectContext.scope);
if (child->typeName() == QLatin1String("Product")) {
- foreach (Item * const additionalProductItem, multiplexProductItem(child))
+ foreach (Item * const additionalProductItem,
+ multiplexProductItem(&dummyProductContext, child)) {
Item::addChild(item, additionalProductItem);
+ }
}
}
@@ -302,8 +304,10 @@ void ModuleLoader::handleProject(ModuleLoaderResult *loadResult, Item *item,
subItem->setParent(projectContext.item);
additionalProjectChildren << qMakePair(subItem, absReferencePath);
if (subItem->typeName() == QLatin1String("Product")) {
- foreach (Item * const additionalProductItem, multiplexProductItem(subItem))
+ foreach (Item * const additionalProductItem,
+ multiplexProductItem(&dummyProductContext, subItem)) {
additionalProjectChildren << qMakePair(additionalProductItem, absReferencePath);
+ }
}
}
foreach (const ItemAndRefPath &irp, additionalProjectChildren) {
@@ -330,8 +334,16 @@ void ModuleLoader::handleProject(ModuleLoaderResult *loadResult, Item *item,
m_reader->popExtraSearchPaths();
}
-QList<Item *> ModuleLoader::multiplexProductItem(Item *productItem)
+QList<Item *> ModuleLoader::multiplexProductItem(ProductContext *dummyContext, Item *productItem)
{
+ // Temporarily attach the qbs module here, in case we need to access one of its properties
+ // to evaluate the profiles property.
+ const QString qbsKey = QLatin1String("qbs");
+ ValuePtr qbsValue = productItem->property(qbsKey); // Retrieve now to restore later.
+ if (qbsValue)
+ qbsValue = qbsValue->clone();
+ loadBaseModule(dummyContext, productItem);
+
// Overriding the product item properties must be done here already, because otherwise
// the "profiles" property would not be overridable.
QString productName = m_evaluator->stringValue(productItem, QLatin1String("name"));
@@ -356,6 +368,14 @@ QList<Item *> ModuleLoader::multiplexProductItem(Item *productItem)
}
}
+ // "Unload" the qbs module again.
+ if (qbsValue)
+ productItem->setProperty(qbsKey, qbsValue);
+ else
+ productItem->removeProperty(qbsKey);
+ productItem->modules().clear();
+ m_validItemPropertyNamesPerItem[productItem].clear();
+
QList<Item *> additionalProductItems;
const QString profileKey = QLatin1String("profile");
productItem->setProperty(profileKey, VariantValue::create(profileNames.first()));
diff --git a/src/lib/corelib/language/moduleloader.h b/src/lib/corelib/language/moduleloader.h
index 09fb1d29b..faf6c91ff 100644
--- a/src/lib/corelib/language/moduleloader.h
+++ b/src/lib/corelib/language/moduleloader.h
@@ -160,7 +160,7 @@ private:
void handleProject(ModuleLoaderResult *loadResult, Item *item, const QString &buildDirectory,
const QSet<QString> &referencedFilePaths);
- QList<Item *> multiplexProductItem(Item *productItem);
+ QList<Item *> multiplexProductItem(ProductContext *dummyContext, Item *productItem);
void handleProduct(ProjectContext *projectContext, Item *item);
void initProductProperties(const ProjectContext *project, Item *item);
void handleSubProject(ProjectContext *projectContext, Item *item,