FIX:fix the issue of macOS crashing easily

jira:[udesk 7578206]

Change-Id: If5e0b2d0969ca70815a5d2c9cca71654c9e1817b
This commit is contained in:
tao wang 2024-10-17 10:08:47 +08:00 committed by lane.wei
parent f4379b3e19
commit 8dfa6839e5
1 changed files with 23 additions and 25 deletions

View File

@ -5016,6 +5016,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);
PresetBundle& preset_bundle = *wxGetApp().preset_bundle;
@ -5047,33 +5063,15 @@ bool SelectMachineDialog::Show(bool show)
m_text_bed_type->Hide();
}
// 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);
}