mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Merge pull request #5397 from MerryMage/do-not-cast-derived-to-base
Config/Layer: Fix accidental cast of RecursiveSection to Section
This commit is contained in:
commit
f1f8beef25
@ -57,8 +57,8 @@ bool Layer::DeleteKey(System system, const std::string& section_name, const std:
|
|||||||
Section* Layer::GetSection(System system, const std::string& section_name)
|
Section* Layer::GetSection(System system, const std::string& section_name)
|
||||||
{
|
{
|
||||||
for (auto& section : m_sections[system])
|
for (auto& section : m_sections[system])
|
||||||
if (!strcasecmp(section.m_name.c_str(), section_name.c_str()))
|
if (!strcasecmp(section->m_name.c_str(), section_name.c_str()))
|
||||||
return §ion;
|
return section.get();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,10 +68,10 @@ Section* Layer::GetOrCreateSection(System system, const std::string& section_nam
|
|||||||
if (!section)
|
if (!section)
|
||||||
{
|
{
|
||||||
if (m_layer == LayerType::Meta)
|
if (m_layer == LayerType::Meta)
|
||||||
m_sections[system].emplace_back(RecursiveSection(m_layer, system, section_name));
|
m_sections[system].emplace_back(std::make_unique<RecursiveSection>(m_layer, system, section_name));
|
||||||
else
|
else
|
||||||
m_sections[system].emplace_back(Section(m_layer, system, section_name));
|
m_sections[system].emplace_back(std::make_unique<Section>(m_layer, system, section_name));
|
||||||
section = &m_sections[system].back();
|
section = m_sections[system].back().get();
|
||||||
}
|
}
|
||||||
return section;
|
return section;
|
||||||
}
|
}
|
||||||
@ -113,7 +113,7 @@ bool Layer::IsDirty() const
|
|||||||
{
|
{
|
||||||
return std::any_of(m_sections.begin(), m_sections.end(), [](const auto& system) {
|
return std::any_of(m_sections.begin(), m_sections.end(), [](const auto& system) {
|
||||||
return std::any_of(system.second.begin(), system.second.end(),
|
return std::any_of(system.second.begin(), system.second.end(),
|
||||||
[](const auto& section) { return section.IsDirty(); });
|
[](const auto& section) { return section->IsDirty(); });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ void Layer::ClearDirty()
|
|||||||
{
|
{
|
||||||
std::for_each(m_sections.begin(), m_sections.end(), [](auto& system) {
|
std::for_each(m_sections.begin(), m_sections.end(), [](auto& system) {
|
||||||
std::for_each(system.second.begin(), system.second.end(),
|
std::for_each(system.second.begin(), system.second.end(),
|
||||||
[](auto& section) { section.ClearDirty(); });
|
[](auto& section) { section->ClearDirty(); });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,8 +140,8 @@ Section* RecursiveLayer::GetOrCreateSection(System system, const std::string& se
|
|||||||
Section* section = Layer::GetSection(system, section_name);
|
Section* section = Layer::GetSection(system, section_name);
|
||||||
if (!section)
|
if (!section)
|
||||||
{
|
{
|
||||||
m_sections[system].emplace_back(RecursiveSection(m_layer, system, section_name));
|
m_sections[system].emplace_back(std::make_unique<RecursiveSection>(m_layer, system, section_name));
|
||||||
section = &m_sections[system].back();
|
section = m_sections[system].back().get();
|
||||||
}
|
}
|
||||||
return section;
|
return section;
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
namespace Config
|
namespace Config
|
||||||
{
|
{
|
||||||
using LayerMap = std::map<System, std::vector<Section>>;
|
using LayerMap = std::map<System, std::vector<std::unique_ptr<Section>>>;
|
||||||
|
|
||||||
class ConfigLayerLoader
|
class ConfigLayerLoader
|
||||||
{
|
{
|
||||||
|
@ -73,8 +73,8 @@ public:
|
|||||||
|
|
||||||
for (const auto& section : system.second)
|
for (const auto& section : system.second)
|
||||||
{
|
{
|
||||||
const std::string section_name = section.GetName();
|
const std::string section_name = section->GetName();
|
||||||
const Config::SectionValueMap& section_values = section.GetValues();
|
const Config::SectionValueMap& section_values = section->GetValues();
|
||||||
|
|
||||||
IniFile::Section* ini_section = ini.GetOrCreateSection(section_name);
|
IniFile::Section* ini_section = ini.GetOrCreateSection(section_name);
|
||||||
|
|
||||||
|
@ -391,10 +391,10 @@ void INIGameConfigLayerLoader::Save(Config::Layer* config_layer)
|
|||||||
{
|
{
|
||||||
for (const auto& section : system.second)
|
for (const auto& section : system.second)
|
||||||
{
|
{
|
||||||
for (const auto& value : section.GetValues())
|
for (const auto& value : section->GetValues())
|
||||||
{
|
{
|
||||||
const auto ini_location =
|
const auto ini_location =
|
||||||
GetINILocationFromConfig({system.first, section.GetName(), value.first});
|
GetINILocationFromConfig({system.first, section->GetName(), value.first});
|
||||||
if (ini_location.first.empty() && ini_location.second.empty())
|
if (ini_location.first.empty() && ini_location.second.empty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user