Remove settings properly (#7676)
parent
18a8fbf465
commit
a29bc8e8ba
|
@ -977,12 +977,7 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
|
||||||
if fields["btn_restore"] then
|
if fields["btn_restore"] then
|
||||||
local setting = settings[selected_setting]
|
local setting = settings[selected_setting]
|
||||||
if setting and setting.type ~= "category" then
|
if setting and setting.type ~= "category" then
|
||||||
if setting.type == "noise_params_2d"
|
core.settings:remove(setting.name)
|
||||||
or setting.type == "noise_params_3d" then
|
|
||||||
core.settings:set_np_group(setting.name, setting.default_table)
|
|
||||||
else
|
|
||||||
core.settings:set(setting.name, setting.default)
|
|
||||||
end
|
|
||||||
core.settings:write()
|
core.settings:write()
|
||||||
core.update_formspec(this:get_formspec())
|
core.update_formspec(this:get_formspec())
|
||||||
end
|
end
|
||||||
|
|
|
@ -228,6 +228,10 @@ bool Settings::updateConfigObject(std::istream &is, std::ostream &os,
|
||||||
(it->second.is_group || it->second.value != value)) {
|
(it->second.is_group || it->second.value != value)) {
|
||||||
printEntry(os, name, it->second, tab_depth);
|
printEntry(os, name, it->second, tab_depth);
|
||||||
was_modified = true;
|
was_modified = true;
|
||||||
|
} else if (it == m_settings.end()) {
|
||||||
|
// Remove by skipping
|
||||||
|
was_modified = true;
|
||||||
|
break;
|
||||||
} else {
|
} else {
|
||||||
os << line << "\n";
|
os << line << "\n";
|
||||||
if (event == SPE_MULTILINE)
|
if (event == SPE_MULTILINE)
|
||||||
|
@ -242,6 +246,10 @@ bool Settings::updateConfigObject(std::istream &is, std::ostream &os,
|
||||||
sanity_check(it->second.group != NULL);
|
sanity_check(it->second.group != NULL);
|
||||||
was_modified |= it->second.group->updateConfigObject(is, os,
|
was_modified |= it->second.group->updateConfigObject(is, os,
|
||||||
"}", tab_depth + 1);
|
"}", tab_depth + 1);
|
||||||
|
} else if (it == m_settings.end()) {
|
||||||
|
// Remove by skipping
|
||||||
|
was_modified = true;
|
||||||
|
break;
|
||||||
} else {
|
} else {
|
||||||
printEntry(os, name, it->second, tab_depth);
|
printEntry(os, name, it->second, tab_depth);
|
||||||
was_modified = true;
|
was_modified = true;
|
||||||
|
@ -901,6 +909,8 @@ bool Settings::remove(const std::string &name)
|
||||||
if (it != m_settings.end()) {
|
if (it != m_settings.end()) {
|
||||||
delete it->second.group;
|
delete it->second.group;
|
||||||
m_settings.erase(it);
|
m_settings.erase(it);
|
||||||
|
|
||||||
|
doCallbacks(name);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue