FIX: fix null pointer in save_printable_area_config api

Jira: STUDIO-4209
Change-Id: I71649e2f7aa0a76e13da7ef6d555c0a66a067799
This commit is contained in:
zhou.xu 2023-09-15 14:10:53 +08:00 committed by Lane.Wei
parent 2b593ce378
commit b32b1d2462
2 changed files with 30 additions and 18 deletions

View file

@ -1825,6 +1825,7 @@ wxBoxSizer *CreatePrinterPresetDialog::create_page2_btns_item(wxWindow *parent)
dlg.ShowModal();
}
}
save_printable_area_config(m_printer_preset);
preset_bundle->printers.save_current_preset(printer_preset_name, true, false, m_printer_preset);
preset_bundle->update_compatible(PresetSelectCompatibleType::Always);
}
@ -2143,21 +2144,31 @@ bool CreatePrinterPresetDialog::save_printable_area_config(Preset *preset)
return true;
}
bool CreatePrinterPresetDialog::check_printable_area() {
double x = 0;
m_bed_size_x_input->GetTextCtrl()->GetValue().ToDouble(&x);
double y = 0;
m_bed_size_y_input->GetTextCtrl()->GetValue().ToDouble(&y);
double dx = 0;
m_bed_origin_x_input->GetTextCtrl()->GetValue().ToDouble(&dx);
double dy = 0;
m_bed_origin_y_input->GetTextCtrl()->GetValue().ToDouble(&dy);
// range check begin
if (x == 0 || y == 0) {
return false;
}
double x0 = 0.0;
double y0 = 0.0;
double x1 = x;
double y1 = y;
if (dx >= x || dy >= y) {
return false;
}
return true;
}
bool CreatePrinterPresetDialog::validate_input_valid()
{
if (m_bed_size_x_input->GetTextCtrl()->GetValue().empty() || m_bed_size_y_input->GetTextCtrl()->GetValue().empty()) {
MessageDialog dlg(this, _L("You did not entered in the printable area of the printer."), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"),
wxYES | wxYES_DEFAULT | wxCENTRE);
dlg.ShowModal();
return false;
}
if (m_print_height_input->GetTextCtrl()->GetValue().empty()) {
MessageDialog dlg(this, _L("You have not entered the maximum printing height of the printer."),
wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), wxYES | wxYES_DEFAULT | wxCENTRE);
dlg.ShowModal();
return false;
}
std::string vender_name = into_u8(m_select_vendor->GetStringSelection());
std::string model_name = into_u8(m_select_model->GetStringSelection());
if (vender_name.empty() || model_name.empty()) {
@ -2178,7 +2189,7 @@ bool CreatePrinterPresetDialog::validate_input_valid()
dlg.ShowModal();
return false;
}
if (save_printable_area_config(m_printer_preset) == false) {
if (check_printable_area() == false) {
MessageDialog dlg(this, _L("Please check bed shape input."), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), wxYES | wxYES_DEFAULT | wxCENTRE);
dlg.ShowModal();
return false;

View file

@ -121,6 +121,7 @@ protected:
void on_preset_model_value_change(wxCommandEvent &e);
void clear_preset_combobox();
bool save_printable_area_config(Preset *preset);
bool check_printable_area();
bool validate_input_valid();
wxArrayString printer_preset_sort_with_nozzle_diameter(const VendorProfile &vendor_profile, float nozzle_diameter);