mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Settings: Fix unittest memory leak, change input types
This commit is contained in:
parent
55e2dd911b
commit
add68369a5
3 changed files with 15 additions and 15 deletions
|
@ -822,22 +822,22 @@ bool Settings::setDefault(const std::string &name, const std::string &value)
|
|||
}
|
||||
|
||||
|
||||
bool Settings::setGroup(const std::string &name, Settings *group)
|
||||
bool Settings::setGroup(const std::string &name, const Settings &group)
|
||||
{
|
||||
// Settings must own the group pointer
|
||||
// avoid double-free by copying the source
|
||||
Settings *copy = new Settings();
|
||||
*copy = *group;
|
||||
*copy = group;
|
||||
return setEntry(name, ©, true, false);
|
||||
}
|
||||
|
||||
|
||||
bool Settings::setGroupDefault(const std::string &name, Settings *group)
|
||||
bool Settings::setGroupDefault(const std::string &name, const Settings &group)
|
||||
{
|
||||
// Settings must own the group pointer
|
||||
// avoid double-free by copying the source
|
||||
Settings *copy = new Settings();
|
||||
*copy = *group;
|
||||
*copy = group;
|
||||
return setEntry(name, ©, true, true);
|
||||
}
|
||||
|
||||
|
@ -1060,7 +1060,7 @@ void Settings::overrideDefaults(Settings *other)
|
|||
{
|
||||
for (const auto &setting : other->m_settings) {
|
||||
if (setting.second.is_group) {
|
||||
setGroupDefault(setting.first, setting.second.group);
|
||||
setGroupDefault(setting.first, *setting.second.group);
|
||||
continue;
|
||||
}
|
||||
const FlagDesc *flagdesc = getFlagDescFallback(setting.first);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue