aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2024-01-19 12:03:37 +0100
committerChristian Kandeler <christian.kandeler@qt.io>2024-01-19 12:03:37 +0100
commit436c3e10794ed9b075486e8a85baada16f4b9703 (patch)
tree4ebf6488780526af8969d598e0ab398835b78c59 /src/lib
parent20de9f30104cec9b29f6c08cea1ae3da4e556a5f (diff)
parent0592a8709b4801b044c9324a41b1c253a2e09a5e (diff)
Merge 2.2 into master
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/corelib/language/item.cpp5
-rw-r--r--src/lib/corelib/language/item.h1
-rw-r--r--src/lib/corelib/loader/dependenciesresolver.cpp28
-rw-r--r--src/lib/corelib/loader/moduleinstantiator.cpp10
4 files changed, 31 insertions, 13 deletions
diff --git a/src/lib/corelib/language/item.cpp b/src/lib/corelib/language/item.cpp
index 16d570499..29fa1417d 100644
--- a/src/lib/corelib/language/item.cpp
+++ b/src/lib/corelib/language/item.cpp
@@ -284,6 +284,11 @@ bool Item::isPresentModule() const
return v && v->type() == Value::JSSourceValueType;
}
+bool Item::isFallbackModule() const
+{
+ return hasProperty(QLatin1String("__fallback"));
+}
+
void Item::setupForBuiltinType(DeprecationWarningMode deprecationMode, Logger &logger)
{
assertModuleLocked();
diff --git a/src/lib/corelib/language/item.h b/src/lib/corelib/language/item.h
index 9ee826d6d..d0dde98c4 100644
--- a/src/lib/corelib/language/item.h
+++ b/src/lib/corelib/language/item.h
@@ -182,6 +182,7 @@ public:
static void removeChild(Item *parent, Item *child);
void dump() const;
bool isPresentModule() const;
+ bool isFallbackModule() const;
void setupForBuiltinType(DeprecationWarningMode deprecationMode, Logger &logger);
void copyProperty(const QString &propertyName, Item *target) const;
void overrideProperties(
diff --git a/src/lib/corelib/loader/dependenciesresolver.cpp b/src/lib/corelib/loader/dependenciesresolver.cpp
index 514105e2c..e49af1600 100644
--- a/src/lib/corelib/loader/dependenciesresolver.cpp
+++ b/src/lib/corelib/loader/dependenciesresolver.cpp
@@ -360,13 +360,6 @@ HandleDependency DependenciesResolver::handleResolvedDependencies()
if (dependency.name.toString() == StringConstants::qbsModule())
throw e;
- // This can happen when a property is set unconditionally on a non-required,
- // non-present dependency. We allow this for user convenience.
- if (!dependency.requiredLocally) {
- state.pendingResolvedDependencies.pop();
- continue;
- }
-
// See QBS-1338 for why we do not abort handling the product.
state.pendingResolvedDependencies.pop();
Item::Modules &modules = m_product.item->modules();
@@ -1001,21 +994,30 @@ void DependenciesResolver::checkForModuleNamePrefixCollision(
return;
for (const Item::Module &m : m_product.item->modules()) {
- if (m.name.length() == dependency.name.length()
- || m.name.front() != dependency.name.front()) {
+ if (m.name.length() == dependency.name.length())
continue;
- }
+
QualifiedId shortName;
QualifiedId longName;
- if (m.name < dependency.name) {
+ if (m.name.length() < dependency.name.length()) {
shortName = m.name;
longName = dependency.name;
} else {
shortName = dependency.name;
longName = m.name;
}
- throw ErrorInfo(Tr::tr("The name of module '%1' is equal to the first component of the "
- "name of module '%2', which is not allowed")
+ const auto isPrefix = [&] {
+ for (int i = 0; i < shortName.length(); ++i) {
+ if (shortName.at(i) != longName.at(i))
+ return false;
+ }
+ return true;
+ };
+ if (!isPrefix())
+ continue;
+
+ throw ErrorInfo(Tr::tr("The name of module '%1' is a prefix of the name of module '%2', "
+ "which is not allowed")
.arg(shortName.toString(), longName.toString()), dependency.location());
}
}
diff --git a/src/lib/corelib/loader/moduleinstantiator.cpp b/src/lib/corelib/loader/moduleinstantiator.cpp
index ab67bc270..1c0359217 100644
--- a/src/lib/corelib/loader/moduleinstantiator.cpp
+++ b/src/lib/corelib/loader/moduleinstantiator.cpp
@@ -135,6 +135,16 @@ void ModuleInstantiator::exchangePlaceholderItem(Item *loadingItem, Item *module
return;
}
+ if (!moduleItemForItemValues->isPresentModule())
+ return;
+
+ // This will yield false negatives for the case where there is an invalid property attached
+ // for a module that is actually found by pkg-config via the fallback provider.
+ // However, this is extremely rare compared to the case where the presence of the fallback
+ // module simply indicates "not present".
+ if (moduleItemForItemValues->isFallbackModule())
+ return;
+
// If the old and the new items are the same, it means the existing item value already
// pointed to a module instance (rather than a placeholder).
// This can happen in two cases: