Fix for - Entering value in Thumbnail setting causes PrusaSlicer to crash

Follow-up 106e520a - During code refactoring "thumbnails" option wasn't correctly processed
This commit is contained in:
YuSanka 2022-01-20 10:06:15 +01:00
parent e0883910dd
commit ded855d0c2
4 changed files with 11 additions and 4 deletions

View file

@ -1136,6 +1136,7 @@ void add_correct_opts_to_diff(const std::string &opt_key, t_config_option_keys&
// list of options with vector variable, which is independent from number of extruders
static const std::vector<std::string> independent_from_extruder_number_options = {
"bed_shape",
"thumbnails",
"filament_ramming_parameters",
"gcode_substitutions",
"compatible_prints",

View file

@ -596,8 +596,8 @@ void ConfigOptionsGroup::back_to_config_value(const DynamicPrintConfig& config,
value = int(nozzle_diameter->values.size());
}
else if (m_opt_map.find(opt_key) == m_opt_map.end() ||
// This option don't have corresponded field
PresetCollection::is_independent_from_extruder_number_option(opt_key) ) {
// This option doesn't have corresponded field
is_option_without_field(opt_key) ) {
value = get_config_value(config, opt_key);
this->change_opt_value(opt_key, value);
return;
@ -980,6 +980,11 @@ bool OptionsGroup::launch_browser(const std::string& path_end)
return wxGetApp().open_browser_with_warning_dialog(OptionsGroup::get_url(path_end), wxGetApp().mainframe->m_tabpanel);
}
bool OptionsGroup::is_option_without_field(const std::string& opt_key)
{
return opt_key!= "thumbnails" // "thumbnails" has related field
&& PresetCollection::is_independent_from_extruder_number_option(opt_key);
}
//-------------------------------------------------------------------------------------------

View file

@ -225,6 +225,7 @@ protected:
public:
static wxString get_url(const std::string& path_end);
static bool launch_browser(const std::string& path_end);
static bool is_option_without_field(const std::string& opt_key);
};
class ConfigOptionsGroup: public OptionsGroup {

View file

@ -532,7 +532,7 @@ void Tab::update_label_colours()
else
color = &m_modified_label_clr;
}
if (PresetCollection::is_independent_from_extruder_number_option(opt.first)) {
if (OptionsGroup::is_option_without_field(opt.first)) {
if (m_colored_Label_colors.find(opt.first) != m_colored_Label_colors.end())
m_colored_Label_colors.at(opt.first) = *color;
continue;
@ -573,7 +573,7 @@ void Tab::decorate()
Field* field = nullptr;
wxColour* colored_label_clr = nullptr;
if(PresetCollection::is_independent_from_extruder_number_option(opt.first))
if(OptionsGroup::is_option_without_field(opt.first))
colored_label_clr = (m_colored_Label_colors.find(opt.first) == m_colored_Label_colors.end()) ? nullptr : &m_colored_Label_colors.at(opt.first);
if (!colored_label_clr) {