From 7184960dce36594d34f872db1aff064fc5a71a6d Mon Sep 17 00:00:00 2001 From: Stone Li Date: Thu, 1 Sep 2022 17:50:56 +0800 Subject: [PATCH] FIX: fix crash when select a printer in lan mode Change-Id: I93f604c900a56e938b16bd377031c331ecc20f43 Signed-off-by: Stone Li --- src/slic3r/GUI/SelectMachine.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/slic3r/GUI/SelectMachine.cpp b/src/slic3r/GUI/SelectMachine.cpp index 74fe8d383..47f815902 100644 --- a/src/slic3r/GUI/SelectMachine.cpp +++ b/src/slic3r/GUI/SelectMachine.cpp @@ -549,11 +549,13 @@ void SelectMachinePopup::update_other_devices() } op->Bind(EVT_CONNECT_LAN_PRINT, [this, mobj](wxCommandEvent &e) { - if (mobj->is_lan_mode_printer()) { - ConnectPrinterDialog dlg(wxGetApp().mainframe, wxID_ANY, _L("Input access code")); - dlg.set_machine_object(mobj); - if (dlg.ShowModal() == wxID_OK) { - wxGetApp().mainframe->jump_to_monitor(mobj->dev_id); + if (mobj) { + if (mobj->is_lan_mode_printer()) { + ConnectPrinterDialog dlg(wxGetApp().mainframe, wxID_ANY, _L("Input access code")); + dlg.set_machine_object(mobj); + if (dlg.ShowModal() == wxID_OK) { + wxGetApp().mainframe->jump_to_monitor(mobj->dev_id); + } } } }); @@ -638,7 +640,8 @@ void SelectMachinePopup::update_user_devices() } op->Bind(EVT_UNBIND_MACHINE, [this, dev, mobj](wxCommandEvent& e) { dev->set_selected_machine(""); - mobj->set_access_code(""); + if (mobj) + mobj->set_access_code(""); MessageDialog msg_wingow(nullptr, _L("Log out successful."), "", wxAPPLY | wxOK); if (msg_wingow.ShowModal() == wxOK) { return; } }); @@ -673,11 +676,13 @@ void SelectMachinePopup::update_user_devices() } op->Bind(EVT_CONNECT_LAN_PRINT, [this, mobj](wxCommandEvent &e) { - if (mobj->is_lan_mode_printer()) { - ConnectPrinterDialog dlg(wxGetApp().mainframe, wxID_ANY, _L("Input access code")); - dlg.set_machine_object(mobj); - if (dlg.ShowModal() == wxID_OK) { - wxGetApp().mainframe->jump_to_monitor(mobj->dev_id); + if (mobj) { + if (mobj->is_lan_mode_printer()) { + ConnectPrinterDialog dlg(wxGetApp().mainframe, wxID_ANY, _L("Input access code")); + dlg.set_machine_object(mobj); + if (dlg.ShowModal() == wxID_OK) { + wxGetApp().mainframe->jump_to_monitor(mobj->dev_id); + } } } });