diff options
| author | Leo Lam <leolino.lam@gmail.com> | 2017-05-09 23:27:46 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-05-09 23:27:46 +0200 |
| commit | f1f8beef258093edfabe2933a36adff7e9ee86c4 (patch) | |
| tree | 2f12f280f9bee0e3f823acc86b57fbf8849e6e67 /Source/Core/Common/Config/Layer.cpp | |
| parent | 4b0cde38392ea8dd7b9887c36998288b8451ee57 (diff) | |
| parent | 32d9428171c3c95064b8227abd679e1e994c2d11 (diff) | |
Merge pull request #5397 from MerryMage/do-not-cast-derived-to-base
Config/Layer: Fix accidental cast of RecursiveSection to Section
Diffstat (limited to 'Source/Core/Common/Config/Layer.cpp')
| -rw-r--r-- | Source/Core/Common/Config/Layer.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Source/Core/Common/Config/Layer.cpp b/Source/Core/Common/Config/Layer.cpp index ee5d5e2ad6..1e17372c82 100644 --- a/Source/Core/Common/Config/Layer.cpp +++ b/Source/Core/Common/Config/Layer.cpp @@ -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) { for (auto& section : m_sections[system]) - if (!strcasecmp(section.m_name.c_str(), section_name.c_str())) - return §ion; + if (!strcasecmp(section->m_name.c_str(), section_name.c_str())) + return section.get(); return nullptr; } @@ -68,10 +68,10 @@ Section* Layer::GetOrCreateSection(System system, const std::string& section_nam if (!section) { 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 - m_sections[system].emplace_back(Section(m_layer, system, section_name)); - section = &m_sections[system].back(); + m_sections[system].emplace_back(std::make_unique<Section>(m_layer, system, section_name)); + section = m_sections[system].back().get(); } 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(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(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); if (!section) { - m_sections[system].emplace_back(RecursiveSection(m_layer, system, section_name)); - section = &m_sections[system].back(); + m_sections[system].emplace_back(std::make_unique<RecursiveSection>(m_layer, system, section_name)); + section = m_sections[system].back().get(); } return section; } |
