FIX: crash if the catched object becomes wild pointer

jira: [none]
Change-Id: I5082ab58f4a6c7177758efcd7ff66a9f73bd0efa
This commit is contained in:
xin.zhang 2025-03-19 10:39:41 +08:00 committed by lane.wei
parent 0e20356871
commit b2256c828b
1 changed files with 12 additions and 12 deletions

View File

@ -2678,6 +2678,8 @@ void StatusPanel::show_recenter_dialog() {
void StatusPanel::show_error_message(MachineObject *obj, bool is_exist, wxString msg, std::string print_error_str, wxString image_url, std::vector<int> used_button) void StatusPanel::show_error_message(MachineObject *obj, bool is_exist, wxString msg, std::string print_error_str, wxString image_url, std::vector<int> used_button)
{ {
const std::string &dev_id = obj ? obj->dev_id : string();
if (is_exist && msg.IsEmpty()) { if (is_exist && msg.IsEmpty()) {
error_info_reset(); error_info_reset();
} else { } else {
@ -2694,13 +2696,12 @@ void StatusPanel::show_error_message(MachineObject *obj, bool is_exist, wxString
m_print_error_dlg = new PrintErrorDialog(this->GetParent(), wxID_ANY, _L("Error")); m_print_error_dlg = new PrintErrorDialog(this->GetParent(), wxID_ANY, _L("Error"));
m_print_error_dlg->update_title_style(_L("Error"), used_button, this); m_print_error_dlg->update_title_style(_L("Error"), used_button, this);
m_print_error_dlg->update_text_image(msg, print_error_str, image_url); m_print_error_dlg->update_text_image(msg, print_error_str, image_url);
m_print_error_dlg->Bind(EVT_SECONDARY_CHECK_CONFIRM, [this, obj](wxCommandEvent& e) { m_print_error_dlg->Bind(EVT_SECONDARY_CHECK_CONFIRM, [this, dev_id](wxCommandEvent &e) {
if (obj) { MachineObject* the_obj = wxGetApp().getDeviceManager()->get_my_machine(dev_id);
obj->command_clean_print_error(obj->subtask_id_, obj->print_error); if (the_obj) { the_obj->command_clean_print_error(the_obj->subtask_id_, the_obj->print_error); }
} });
});
m_print_error_dlg->Bind(EVT_SECONDARY_CHECK_RETRY, [this, obj](wxCommandEvent& e) { m_print_error_dlg->Bind(EVT_SECONDARY_CHECK_RETRY, [this](wxCommandEvent& e) {
if (m_ams_control) { if (m_ams_control) {
m_ams_control->on_retry(); m_ams_control->on_retry();
} }
@ -2742,13 +2743,12 @@ void StatusPanel::show_error_message(MachineObject *obj, bool is_exist, wxString
m_print_error_dlg_no_action->update_title_style(_L("Warning"), SecondaryCheckDialog::ButtonStyle::ONLY_CONFIRM, this); m_print_error_dlg_no_action->update_title_style(_L("Warning"), SecondaryCheckDialog::ButtonStyle::ONLY_CONFIRM, this);
} }
m_print_error_dlg_no_action->update_text(error_code_msg); m_print_error_dlg_no_action->update_text(error_code_msg);
m_print_error_dlg_no_action->Bind(EVT_SECONDARY_CHECK_CONFIRM, [this, obj](wxCommandEvent& e) { m_print_error_dlg_no_action->Bind(EVT_SECONDARY_CHECK_CONFIRM, [this, dev_id](wxCommandEvent &e) {
if (obj) { MachineObject *the_obj = wxGetApp().getDeviceManager()->get_my_machine(dev_id);
obj->command_clean_print_error(obj->subtask_id_, obj->print_error); if (the_obj) { the_obj->command_clean_print_error(the_obj->subtask_id_, the_obj->print_error); }
} });
});
m_print_error_dlg_no_action->Bind(EVT_SECONDARY_CHECK_RETRY, [this, obj](wxCommandEvent& e) { m_print_error_dlg_no_action->Bind(EVT_SECONDARY_CHECK_RETRY, [this](wxCommandEvent& e) {
if (m_ams_control) { if (m_ams_control) {
m_ams_control->on_retry(); m_ams_control->on_retry();
} }