mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-07 23:17:35 -06:00
Fix various memory leaks
(cherry picked from commit prusa3d/PrusaSlicer@deb17c5920)
This commit is contained in:
parent
7907426d00
commit
499b9d1be8
7 changed files with 79 additions and 51 deletions
|
@ -2572,8 +2572,8 @@ bool Tab::validate_custom_gcode(const wxString& title, const std::string& gcode)
|
|||
return !invalid;
|
||||
}
|
||||
|
||||
static void validate_custom_gcode_cb(Tab* tab, ConfigOptionsGroupShp opt_group, const t_config_option_key& opt_key, const boost::any& value) {
|
||||
tab->validate_custom_gcodes_was_shown = !Tab::validate_custom_gcode(opt_group->title, boost::any_cast<std::string>(value));
|
||||
static void validate_custom_gcode_cb(Tab* tab, const wxString& title, const t_config_option_key& opt_key, const boost::any& value) {
|
||||
tab->validate_custom_gcodes_was_shown = !Tab::validate_custom_gcode(title, boost::any_cast<std::string>(value));
|
||||
tab->update_dirty();
|
||||
tab->on_value_change(opt_key, value);
|
||||
}
|
||||
|
@ -2590,18 +2590,19 @@ void TabFilament::add_filament_overrides_page()
|
|||
//BBS
|
||||
line = optgroup->create_single_option_line(optgroup->get_option(opt_key));
|
||||
|
||||
line.near_label_widget = [this, optgroup, opt_key, opt_index](wxWindow* parent) {
|
||||
line.near_label_widget = [this, optgroup_wk = ConfigOptionsGroupWkp(optgroup), opt_key, opt_index](wxWindow* parent) {
|
||||
wxCheckBox* check_box = new wxCheckBox(parent, wxID_ANY, "");
|
||||
|
||||
check_box->Bind(wxEVT_CHECKBOX, [optgroup, opt_key, opt_index](wxCommandEvent& evt) {
|
||||
check_box->Bind(wxEVT_CHECKBOX, [optgroup_wk, opt_key, opt_index](wxCommandEvent& evt) {
|
||||
const bool is_checked = evt.IsChecked();
|
||||
Field* field = optgroup->get_fieldc(opt_key, opt_index);
|
||||
if (field != nullptr) {
|
||||
field->toggle(is_checked);
|
||||
if (is_checked)
|
||||
field->set_last_meaningful_value();
|
||||
else
|
||||
field->set_na_value();
|
||||
if (auto optgroup_sh = optgroup_wk.lock(); optgroup_sh) {
|
||||
if (Field *field = optgroup_sh->get_fieldc(opt_key, opt_index); field != nullptr) {
|
||||
field->toggle(is_checked);
|
||||
if (is_checked)
|
||||
field->set_last_meaningful_value();
|
||||
else
|
||||
field->set_na_value();
|
||||
}
|
||||
}
|
||||
}, check_box->GetId());
|
||||
|
||||
|
@ -2758,7 +2759,7 @@ void TabFilament::build()
|
|||
line.append_option(optgroup->get_option("textured_plate_temp"));
|
||||
optgroup->append_line(line);
|
||||
|
||||
optgroup->m_on_change = [this, optgroup](t_config_option_key opt_key, boost::any value)
|
||||
optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value)
|
||||
{
|
||||
DynamicPrintConfig& filament_config = wxGetApp().preset_bundle->filaments.get_edited_preset().config;
|
||||
|
||||
|
@ -2853,8 +2854,8 @@ void TabFilament::build()
|
|||
|
||||
page = add_options_page(L("Advanced"), "advanced");
|
||||
optgroup = page->new_optgroup(L("Filament start G-code"), L"param_gcode", 0);
|
||||
optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) {
|
||||
validate_custom_gcode_cb(this, optgroup, opt_key, value);
|
||||
optgroup->m_on_change = [this, &optgroup_title = optgroup->title](const t_config_option_key& opt_key, const boost::any& value) {
|
||||
validate_custom_gcode_cb(this, optgroup_title, opt_key, value);
|
||||
};
|
||||
option = optgroup->get_option("filament_start_gcode");
|
||||
option.opt.full_width = true;
|
||||
|
@ -2863,8 +2864,8 @@ void TabFilament::build()
|
|||
optgroup->append_single_option_line(option);
|
||||
|
||||
optgroup = page->new_optgroup(L("Filament end G-code"), L"param_gcode", 0);
|
||||
optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) {
|
||||
validate_custom_gcode_cb(this, optgroup, opt_key, value);
|
||||
optgroup->m_on_change = [this, &optgroup_title = optgroup->title](const t_config_option_key& opt_key, const boost::any& value) {
|
||||
validate_custom_gcode_cb(this, optgroup_title, opt_key, value);
|
||||
};
|
||||
option = optgroup->get_option("filament_end_gcode");
|
||||
option.opt.full_width = true;
|
||||
|
@ -3170,8 +3171,8 @@ void TabPrinter::build_fff()
|
|||
const int notes_field_height = 25; // 250
|
||||
page = add_options_page(L("Machine gcode"), "cog");
|
||||
optgroup = page->new_optgroup(L("Machine start G-code"), L"param_gcode", 0);
|
||||
optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) {
|
||||
validate_custom_gcode_cb(this, optgroup, opt_key, value);
|
||||
optgroup->m_on_change = [this, &optgroup_title = optgroup->title](const t_config_option_key& opt_key, const boost::any& value) {
|
||||
validate_custom_gcode_cb(this, optgroup_title, opt_key, value);
|
||||
};
|
||||
option = optgroup->get_option("machine_start_gcode");
|
||||
option.opt.full_width = true;
|
||||
|
@ -3180,8 +3181,8 @@ void TabPrinter::build_fff()
|
|||
optgroup->append_single_option_line(option);
|
||||
|
||||
optgroup = page->new_optgroup(L("Machine end G-code"), L"param_gcode", 0);
|
||||
optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) {
|
||||
validate_custom_gcode_cb(this, optgroup, opt_key, value);
|
||||
optgroup->m_on_change = [this, &optgroup_title = optgroup->title](const t_config_option_key& opt_key, const boost::any& value) {
|
||||
validate_custom_gcode_cb(this, optgroup_title, opt_key, value);
|
||||
};
|
||||
option = optgroup->get_option("machine_end_gcode");
|
||||
option.opt.full_width = true;
|
||||
|
@ -3190,8 +3191,8 @@ void TabPrinter::build_fff()
|
|||
optgroup->append_single_option_line(option);
|
||||
|
||||
optgroup = page->new_optgroup(L("Before layer change G-code"),"param_gcode", 0);
|
||||
optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) {
|
||||
validate_custom_gcode_cb(this, optgroup, opt_key, value);
|
||||
optgroup->m_on_change = [this, &optgroup_title = optgroup->title](const t_config_option_key& opt_key, const boost::any& value) {
|
||||
validate_custom_gcode_cb(this, optgroup_title, opt_key, value);
|
||||
};
|
||||
option = optgroup->get_option("before_layer_change_gcode");
|
||||
option.opt.full_width = true;
|
||||
|
@ -3200,8 +3201,8 @@ void TabPrinter::build_fff()
|
|||
optgroup->append_single_option_line(option);
|
||||
|
||||
optgroup = page->new_optgroup(L("Layer change G-code"), L"param_gcode", 0);
|
||||
optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) {
|
||||
validate_custom_gcode_cb(this, optgroup, opt_key, value);
|
||||
optgroup->m_on_change = [this, &optgroup_title = optgroup->title](const t_config_option_key& opt_key, const boost::any& value) {
|
||||
validate_custom_gcode_cb(this, optgroup_title, opt_key, value);
|
||||
};
|
||||
option = optgroup->get_option("layer_change_gcode");
|
||||
option.opt.full_width = true;
|
||||
|
@ -3210,8 +3211,8 @@ void TabPrinter::build_fff()
|
|||
optgroup->append_single_option_line(option);
|
||||
|
||||
optgroup = page->new_optgroup(L("Time lapse G-code"), L"param_gcode", 0);
|
||||
optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) {
|
||||
validate_custom_gcode_cb(this, optgroup, opt_key, value);
|
||||
optgroup->m_on_change = [this, &optgroup_title = optgroup->title](const t_config_option_key& opt_key, const boost::any& value) {
|
||||
validate_custom_gcode_cb(this, optgroup_title, opt_key, value);
|
||||
};
|
||||
option = optgroup->get_option("time_lapse_gcode");
|
||||
option.opt.full_width = true;
|
||||
|
@ -3220,8 +3221,8 @@ void TabPrinter::build_fff()
|
|||
optgroup->append_single_option_line(option);
|
||||
|
||||
optgroup = page->new_optgroup(L("Change filament G-code"), L"param_gcode", 0);
|
||||
optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) {
|
||||
validate_custom_gcode_cb(this, optgroup, opt_key, value);
|
||||
optgroup->m_on_change = [this, &optgroup_title = optgroup->title](const t_config_option_key& opt_key, const boost::any& value) {
|
||||
validate_custom_gcode_cb(this, optgroup_title, opt_key, value);
|
||||
};
|
||||
option = optgroup->get_option("change_filament_gcode");
|
||||
option.opt.full_width = true;
|
||||
|
@ -3230,8 +3231,8 @@ void TabPrinter::build_fff()
|
|||
optgroup->append_single_option_line(option);
|
||||
|
||||
optgroup = page->new_optgroup(L("Pause G-code"), L"param_gcode", 0);
|
||||
optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) {
|
||||
validate_custom_gcode_cb(this, optgroup, opt_key, value);
|
||||
optgroup->m_on_change = [this, &optgroup_title = optgroup->title](const t_config_option_key& opt_key, const boost::any& value) {
|
||||
validate_custom_gcode_cb(this, optgroup_title, opt_key, value);
|
||||
};
|
||||
option = optgroup->get_option("machine_pause_gcode");
|
||||
option.opt.is_code = true;
|
||||
|
@ -3239,8 +3240,8 @@ void TabPrinter::build_fff()
|
|||
optgroup->append_single_option_line(option);
|
||||
|
||||
optgroup = page->new_optgroup(L("Template Custom G-code"), L"param_gcode", 0);
|
||||
optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) {
|
||||
validate_custom_gcode_cb(this, optgroup, opt_key, value);
|
||||
optgroup->m_on_change = [this, &optgroup_title = optgroup->title](const t_config_option_key& opt_key, const boost::any& value) {
|
||||
validate_custom_gcode_cb(this, optgroup_title, opt_key, value);
|
||||
};
|
||||
option = optgroup->get_option("template_custom_gcode");
|
||||
option.opt.is_code = true;
|
||||
|
@ -3468,7 +3469,7 @@ if (is_marlin_flavor)
|
|||
auto optgroup = page->new_optgroup(L("Single extruder multimaterial setup"));
|
||||
optgroup->append_single_option_line("single_extruder_multi_material", "semm");
|
||||
// Orca: we only support Single Extruder Multi Material, so it's always enabled
|
||||
// optgroup->m_on_change = [this, optgroup](const t_config_option_key &opt_key, const boost::any &value) {
|
||||
// optgroup->m_on_change = [this](const t_config_option_key &opt_key, const boost::any &value) {
|
||||
// wxTheApp->CallAfter([this, opt_key, value]() {
|
||||
// if (opt_key == "single_extruder_multi_material") {
|
||||
// build_unregular_pages();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue