FIX: fix crash when exiting studio
Change-Id: I91f6cde208e044aae20b40e4b79159f6cd46356c Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
parent
d9ad79e922
commit
3c8d9be77e
|
@ -2981,11 +2981,15 @@ std::map<std::string, MachineObject*> DeviceManager::get_my_machine_list()
|
||||||
std::map<std::string, MachineObject*> result;
|
std::map<std::string, MachineObject*> result;
|
||||||
|
|
||||||
for (auto it = userMachineList.begin(); it != userMachineList.end(); it++) {
|
for (auto it = userMachineList.begin(); it != userMachineList.end(); it++) {
|
||||||
|
if (!it->second)
|
||||||
|
continue;
|
||||||
if (!it->second->is_lan_mode_printer())
|
if (!it->second->is_lan_mode_printer())
|
||||||
result.insert(std::make_pair(it->first, it->second));
|
result.insert(std::make_pair(it->first, it->second));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto it = localMachineList.begin(); it != localMachineList.end(); it++) {
|
for (auto it = localMachineList.begin(); it != localMachineList.end(); it++) {
|
||||||
|
if (!it->second)
|
||||||
|
continue;
|
||||||
if (it->second->has_access_right() && it->second->is_avaliable() && it->second->is_lan_mode_printer()) {
|
if (it->second->has_access_right() && it->second->is_avaliable() && it->second->is_lan_mode_printer()) {
|
||||||
// remove redundant in userMachineList
|
// remove redundant in userMachineList
|
||||||
if (result.find(it->first) == result.end()) {
|
if (result.find(it->first) == result.end()) {
|
||||||
|
|
|
@ -279,7 +279,9 @@ void MachineObjectPanel::on_mouse_left_up(wxMouseEvent &evt)
|
||||||
event.SetEventObject(this);
|
event.SetEventObject(this);
|
||||||
GetEventHandler()->ProcessEvent(event);
|
GetEventHandler()->ProcessEvent(event);
|
||||||
} else {
|
} else {
|
||||||
|
if (m_info) {
|
||||||
wxGetApp().mainframe->jump_to_monitor(m_info->dev_id);
|
wxGetApp().mainframe->jump_to_monitor(m_info->dev_id);
|
||||||
|
}
|
||||||
//wxGetApp().mainframe->SetFocus();
|
//wxGetApp().mainframe->SetFocus();
|
||||||
wxCommandEvent event(EVT_DISSMISS_MACHINE_LIST);
|
wxCommandEvent event(EVT_DISSMISS_MACHINE_LIST);
|
||||||
event.SetEventObject(this->GetParent());
|
event.SetEventObject(this->GetParent());
|
||||||
|
@ -287,7 +289,7 @@ void MachineObjectPanel::on_mouse_left_up(wxMouseEvent &evt)
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (m_info->is_lan_mode_printer()) {
|
if (m_info && m_info->is_lan_mode_printer()) {
|
||||||
if (m_info->has_access_right() && m_info->is_avaliable()) {
|
if (m_info->has_access_right() && m_info->is_avaliable()) {
|
||||||
wxGetApp().mainframe->jump_to_monitor(m_info->dev_id);
|
wxGetApp().mainframe->jump_to_monitor(m_info->dev_id);
|
||||||
} else {
|
} else {
|
||||||
|
@ -299,7 +301,7 @@ void MachineObjectPanel::on_mouse_left_up(wxMouseEvent &evt)
|
||||||
wxGetApp().mainframe->jump_to_monitor(m_info->dev_id);
|
wxGetApp().mainframe->jump_to_monitor(m_info->dev_id);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (m_info->is_lan_mode_printer()) {
|
if (m_info && m_info->is_lan_mode_printer()) {
|
||||||
wxCommandEvent event(EVT_CONNECT_LAN_PRINT);
|
wxCommandEvent event(EVT_CONNECT_LAN_PRINT);
|
||||||
event.SetEventObject(this);
|
event.SetEventObject(this);
|
||||||
wxPostEvent(this, event);
|
wxPostEvent(this, event);
|
||||||
|
@ -2233,6 +2235,7 @@ EditDevNameDialog::~EditDevNameDialog() {}
|
||||||
void EditDevNameDialog::set_machine_obj(MachineObject *obj)
|
void EditDevNameDialog::set_machine_obj(MachineObject *obj)
|
||||||
{
|
{
|
||||||
m_info = obj;
|
m_info = obj;
|
||||||
|
if (m_info)
|
||||||
m_textCtr->GetTextCtrl()->SetValue(from_u8(m_info->dev_name));
|
m_textCtr->GetTextCtrl()->SetValue(from_u8(m_info->dev_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2291,6 +2294,7 @@ void EditDevNameDialog::on_edit_name(wxCommandEvent &e)
|
||||||
if (dev) {
|
if (dev) {
|
||||||
auto utf8_str = new_dev_name.ToUTF8();
|
auto utf8_str = new_dev_name.ToUTF8();
|
||||||
auto name = std::string(utf8_str.data(), utf8_str.length());
|
auto name = std::string(utf8_str.data(), utf8_str.length());
|
||||||
|
if (m_info)
|
||||||
dev->modify_device_name(m_info->dev_id, name);
|
dev->modify_device_name(m_info->dev_id, name);
|
||||||
}
|
}
|
||||||
DPIDialog::EndModal(wxID_CLOSE);
|
DPIDialog::EndModal(wxID_CLOSE);
|
||||||
|
|
Loading…
Reference in New Issue