Follow-up 3b1f1d9444 fixes:

Tab: Fixed rename_preset().
 * Presets weren't sorted after preset renaming.
 * New selected preset wasn't updated on the Plater.
Preset: Fixed delete_preset().
 * Selected preset wasn't updated after preset deletion.
This commit is contained in:
YuSanka 2022-09-14 15:09:33 +02:00
parent 369e08aed1
commit 82716cd78c
2 changed files with 46 additions and 16 deletions

View file

@ -947,6 +947,11 @@ bool PresetCollection::delete_current_preset()
bool PresetCollection::delete_preset(const std::string& name)
{
if (name == this->get_selected_preset().name)
return delete_current_preset();
const std::string selected_preset_name = this->get_selected_preset_name();
auto it = this->find_preset_internal(name);
const Preset& preset = *it;
@ -957,6 +962,10 @@ bool PresetCollection::delete_preset(const std::string& name)
boost::nowide::remove(preset.file.c_str());
}
m_presets.erase(it);
// update selected preset
this->select_preset_by_name(selected_preset_name, true);
return true;
}