aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/corelib
diff options
context:
space:
mode:
authorIvan Komissarov <abbapoh@gmail.com>2020-10-29 22:17:31 +0100
committerIvan Komissarov <ABBAPOH@gmail.com>2020-10-30 14:37:50 +0000
commit7668c398485655f4f884c0eb6efbecabcefee61b (patch)
tree81e8fa2920a3701cf82ca7ec10a66b35d7bc20d4 /src/lib/corelib
parent5937d5f3b13b9f4d8f85199622b4d62204e78b0e (diff)
Use std::optional to store theModuleProviderConfig
Using map+bool is a bit clumsy Change-Id: Ic2b8c354c583f19cde946ec24a69ed90e560cd11 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/lib/corelib')
-rw-r--r--src/lib/corelib/language/moduleloader.cpp18
-rw-r--r--src/lib/corelib/language/moduleloader.h3
2 files changed, 10 insertions, 11 deletions
diff --git a/src/lib/corelib/language/moduleloader.cpp b/src/lib/corelib/language/moduleloader.cpp
index 5c4033c3f..6e92943f9 100644
--- a/src/lib/corelib/language/moduleloader.cpp
+++ b/src/lib/corelib/language/moduleloader.cpp
@@ -3802,13 +3802,14 @@ QStringList ModuleLoader::findExistingModulePaths(
QVariantMap ModuleLoader::moduleProviderConfig(ModuleLoader::ProductContext &product)
{
- if (product.moduleProviderConfigRetrieved)
- return product.theModuleProviderConfig;
+ if (product.theModuleProviderConfig)
+ return *product.theModuleProviderConfig;
+ QVariantMap providerConfig;
const ItemValueConstPtr configItemValue
= product.item->itemProperty(StringConstants::moduleProviders());
if (configItemValue) {
const std::function<void(const Item *, QualifiedId)> collectMap
- = [this, &product, &collectMap](const Item *item, const QualifiedId &name) {
+ = [this, &providerConfig, &collectMap](const Item *item, const QualifiedId &name) {
const Item::PropertyMap &props = item->properties();
for (auto it = props.begin(); it != props.end(); ++it) {
QVariant value;
@@ -3826,9 +3827,9 @@ QVariantMap ModuleLoader::moduleProviderConfig(ModuleLoader::ProductContext &pro
value = static_cast<VariantValue *>(it.value().get())->value();
break;
}
- QVariantMap m = product.theModuleProviderConfig.value(name.toString()).toMap();
+ QVariantMap m = providerConfig.value(name.toString()).toMap();
m.insert(it.key(), value);
- product.theModuleProviderConfig.insert(name.toString(), m);
+ providerConfig.insert(name.toString(), m);
}
};
configItemValue->item()->setScope(product.item);
@@ -3841,15 +3842,14 @@ QVariantMap ModuleLoader::moduleProviderConfig(ModuleLoader::ProductContext &pro
const QVariantMap providerConfigFromBuildConfig = it.value().toMap();
if (providerConfigFromBuildConfig.empty())
continue;
- QVariantMap currentMapForProvider = product.theModuleProviderConfig.value(provider).toMap();
+ QVariantMap currentMapForProvider = providerConfig.value(provider).toMap();
for (auto propIt = providerConfigFromBuildConfig.begin();
propIt != providerConfigFromBuildConfig.end(); ++propIt) {
currentMapForProvider.insert(propIt.key(), propIt.value());
}
- product.theModuleProviderConfig.insert(provider, currentMapForProvider);
+ providerConfig.insert(provider, currentMapForProvider);
}
- product.moduleProviderConfigRetrieved = true;
- return product.theModuleProviderConfig;
+ return *(product.theModuleProviderConfig = std::move(providerConfig));
}
ModuleLoader::ModuleProviderResult ModuleLoader::findModuleProvider(const QualifiedId &name,
diff --git a/src/lib/corelib/language/moduleloader.h b/src/lib/corelib/language/moduleloader.h
index df853e77f..4033dd42d 100644
--- a/src/lib/corelib/language/moduleloader.h
+++ b/src/lib/corelib/language/moduleloader.h
@@ -187,8 +187,7 @@ private:
std::vector<QStringList> newlyAddedModuleProviderSearchPaths;
Set<QualifiedId> knownModuleProviders;
- QVariantMap theModuleProviderConfig;
- bool moduleProviderConfigRetrieved = false;
+ std::optional<QVariantMap> theModuleProviderConfig;
// The key corresponds to DeferredDependsContext.exportingProductItem, which is the
// only value from that data structure that we still need here.