FIX:fix the issue of macOS crashing easily

jira:[udesk 7578206]

Change-Id: If5e0b2d0969ca70815a5d2c9cca71654c9e1817b
(cherry picked from commit 8dfa6839e5e3a9bebb03616ff6d0c0c1699ad22f)
This commit is contained in:
tao wang 2024-10-17 10:08:47 +08:00 committed by Noisyfox
parent d841b2d178
commit 3141dbd57c

View file

@ -4109,6 +4109,22 @@ void SelectMachineDialog::sys_color_changed()
bool SelectMachineDialog::Show(bool show)
{
if (show) {
m_refresh_timer->Start(LIST_REFRESH_INTERVAL);
} else {
m_refresh_timer->Stop();
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (dev) {
MachineObject *obj_ = dev->get_selected_machine();
if (obj_ && obj_->connection_type() == "cloud" /*&& m_print_type == FROM_SDCARD_VIEW*/) {
if (obj_->is_connected()) { obj_->disconnect(); }
}
}
return DPIDialog::Show(false);
}
show_status(PrintDialogStatus::PrintStatusInit);
@ -4131,33 +4147,15 @@ bool SelectMachineDialog::Show(bool show)
m_text_bed_type->SetLabelText(plate_name);
m_text_bed_type->Show();
}
// set default value when show this dialog
if (show) {
m_refresh_timer->Start(LIST_REFRESH_INTERVAL);
show_status(PrintDialogStatus::PrintStatusInit);
wxGetApp().UpdateDlgDarkUI(this);
wxGetApp().reset_to_active();
set_default();
update_user_machine_list();
wxGetApp().UpdateDlgDarkUI(this);
wxGetApp().reset_to_active();
set_default();
update_user_machine_list();
Layout();
Fit();
CenterOnParent();
}
else {
m_refresh_timer->Stop();
DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (dev) {
MachineObject* obj_ = dev->get_selected_machine();
if (obj_ && obj_->connection_type() == "cloud" /*&& m_print_type == FROM_SDCARD_VIEW*/) {
if (obj_->is_connected()) {
obj_->disconnect();
}
}
}
}
Layout();
Fit();
CenterOnParent();
return DPIDialog::Show(show);
}