mirror of
https://github.com/electronicarts/CNC_TS_and_RA2_Mission_Editor.git
synced 2025-04-30 17:11:40 -04:00
fixed bug that INI group might already been destroyed while iterating the group
This commit is contained in:
parent
f1b969219a
commit
48c9065537
2 changed files with 15 additions and 4 deletions
|
@ -103,12 +103,17 @@ public:
|
|||
const CString& m_section;
|
||||
};
|
||||
|
||||
IniSectionGroup(const IniFileGroup& source, const CString& secName) :
|
||||
m_source(source),
|
||||
IniSectionGroup(IniFileGroup&& source, const CString& secName) :
|
||||
m_source(std::move(source)),
|
||||
m_section(secName)
|
||||
{
|
||||
}
|
||||
|
||||
IniSectionGroup(const IniFileGroup& source, const CString& secName) :
|
||||
IniSectionGroup(IniFileGroup(source), secName)
|
||||
{
|
||||
}
|
||||
|
||||
Iterator begin() const {
|
||||
auto groupBeg = m_source.begin();
|
||||
auto [secItBeg, secItEnd] = acquireNextKvGroup(groupBeg);
|
||||
|
@ -146,6 +151,6 @@ private:
|
|||
return acquireNextKvGroup(m_section, beg, m_source.end());
|
||||
}
|
||||
|
||||
const IniFileGroup& m_source;
|
||||
const IniFileGroup m_source;
|
||||
CString m_section;
|
||||
};
|
||||
|
|
|
@ -29,12 +29,18 @@ TEST(IniFileGroup, ValidIniWithValidContentTest) {
|
|||
|
||||
auto const bldTypes = group.GetSection("BuildingTypes");
|
||||
auto idx = 0;
|
||||
//for (auto const& [key, val] : bldTypes) {
|
||||
|
||||
for (auto it = bldTypes.begin(); it != bldTypes.end(); ++it) {
|
||||
auto const& [key, val] = *it;
|
||||
EXPECT_EQ(val, referenceList[idx++]);
|
||||
}
|
||||
|
||||
// This is to test RHS issue
|
||||
idx = 0;
|
||||
for (auto const& [key, val] : group.GetSection("BuildingTypes")) {
|
||||
EXPECT_EQ(val, referenceList[idx++]);
|
||||
}
|
||||
|
||||
EXPECT_EQ(group.GetString("GACNST", "Strength"), "2000");
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue