From 5869ac71e3655eeeeb822518941a7cd0b7526ba5 Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Wed, 28 Oct 2020 00:36:49 +0000 Subject: [PATCH] Merge all composing variables, not just those in destination already This resolves a regression where the local openmw.cfg doesn't exist, so we fall back to the global openmw.cfg, but because we've not loaded anything from the local openmw.cfg, there are no variables with which to merge. --- components/files/configurationmanager.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/components/files/configurationmanager.cpp b/components/files/configurationmanager.cpp index c7847b1227..92d35a6b65 100644 --- a/components/files/configurationmanager.cpp +++ b/components/files/configurationmanager.cpp @@ -87,7 +87,7 @@ boost::program_options::variables_map ConfigurationManager::separateComposingVar boost::program_options::variables_map composingVariables; for (auto itr = variables.begin(); itr != variables.end();) { - if (description.find((*itr).first, false).semantic()->is_composing()) + if (description.find(itr->first, false).semantic()->is_composing()) { composingVariables.emplace(*itr); itr = variables.erase(itr); @@ -100,14 +100,23 @@ boost::program_options::variables_map ConfigurationManager::separateComposingVar void ConfigurationManager::mergeComposingVariables(boost::program_options::variables_map & first, boost::program_options::variables_map & second, boost::program_options::options_description& description) { - for (auto& [name, variableValue] : first) + for (const auto& option : description.options()) { - if (description.find(name, false).semantic()->is_composing()) + if (option->semantic()->is_composing()) { + std::string name = option->canonical_display_name(); + + auto firstPosition = first.find(name); + if (firstPosition == first.end()) + { + first.emplace(name, second[name]); + continue; + } + if (second[name].defaulted() || second[name].empty()) continue; - boost::any& firstValue = variableValue.value(); + boost::any& firstValue = firstPosition->second.value(); const boost::any& secondValue = second[name].value(); if (firstValue.type() == typeid(Files::EscapePathContainer))