FIX: File panel crash on scroll

Change-Id: I56833a376fa52c960efea5fbd60003367ba410c2
Jira: STUDIO-5337, STUDIO-5513
This commit is contained in:
chunmao.guo 2023-12-06 13:26:38 +08:00 committed by Lane.Wei
parent f2b8d78230
commit e9c4e8fec9
6 changed files with 29 additions and 16 deletions

View File

@ -46,6 +46,8 @@ ImageGrid::ImageGrid(wxWindow * parent)
, m_model_time_icon(this, "model_time", 14) , m_model_time_icon(this, "model_time", 14)
, m_model_weight_icon(this, "model_weight", 14) , m_model_weight_icon(this, "model_weight", 14)
{ {
m_cell_size.Set(396, 228);
SetBackgroundStyle(wxBG_STYLE_PAINT); SetBackgroundStyle(wxBG_STYLE_PAINT);
SetBackgroundColour(0xEEEEEE); SetBackgroundColour(0xEEEEEE);
SetFont(Label::Head_20); SetFont(Label::Head_20);

View File

@ -218,7 +218,8 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj)
m_remote_support = false; m_remote_support = false;
m_model_download_support = false; m_model_download_support = false;
} }
if (machine == m_machine && m_image_grid->GetFileSystem()) { Enable(obj && obj->is_connected() && obj->m_push_count > 0);
if (machine == m_machine && (m_image_grid->GetFileSystem() || (!m_local_support && !m_remote_support))) {
if (m_waiting_enable && IsEnabled()) { if (m_waiting_enable && IsEnabled()) {
auto fs = m_image_grid->GetFileSystem(); auto fs = m_image_grid->GetFileSystem();
if (fs) fs->Retry(); if (fs) fs->Retry();
@ -237,6 +238,8 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj)
SetSelecting(false); SetSelecting(false);
if (m_machine.empty()) { if (m_machine.empty()) {
m_image_grid->SetStatus(m_bmp_failed, _L("No printers.")); m_image_grid->SetStatus(m_bmp_failed, _L("No printers."));
} else if (!IsEnabled()) {
m_image_grid->SetStatus(m_bmp_failed, _L("Initialize failed (Device connection not ready)!"));
} else if (!m_local_support && !m_remote_support) { } else if (!m_local_support && !m_remote_support) {
m_image_grid->SetStatus(m_bmp_failed, _L("Initialize failed (Not supported on the current printer version)!")); m_image_grid->SetStatus(m_bmp_failed, _L("Initialize failed (Not supported on the current printer version)!"));
} else { } else {

View File

@ -120,6 +120,7 @@ void MediaPlayCtrl::SetMachineObject(MachineObject* obj)
m_remote_support = true; m_remote_support = true;
m_device_busy = false; m_device_busy = false;
} }
Enable(obj && obj->is_connected() && obj->m_push_count > 0);
if (machine == m_machine) { if (machine == m_machine) {
if (m_last_state == MEDIASTATE_IDLE && IsEnabled()) if (m_last_state == MEDIASTATE_IDLE && IsEnabled())
Play(); Play();

View File

@ -348,8 +348,8 @@ void MonitorPanel::update_all()
} }
m_status_info_panel->obj = obj; m_status_info_panel->obj = obj;
m_status_info_panel->m_media_play_ctrl->SetMachineObject(obj);
m_upgrade_panel->update(obj); m_upgrade_panel->update(obj);
m_status_info_panel->m_media_play_ctrl->SetMachineObject(obj);
m_media_file_panel->SetMachineObject(obj); m_media_file_panel->SetMachineObject(obj);
m_side_tools->update_status(obj); m_side_tools->update_status(obj);
@ -476,7 +476,6 @@ Freeze();
m_status_info_panel->show_status(status); m_status_info_panel->show_status(status);
m_hms_panel->show_status(status); m_hms_panel->show_status(status);
m_upgrade_panel->show_status(status); m_upgrade_panel->show_status(status);
m_media_file_panel->Enable(status == MonitorStatus::MONITOR_NORMAL);
if ((status & (int)MonitorStatus::MONITOR_NO_PRINTER) != 0) { if ((status & (int)MonitorStatus::MONITOR_NO_PRINTER) != 0) {
set_default(); set_default();

View File

@ -4022,13 +4022,11 @@ void StatusPanel::show_status(int status)
m_calibration_btn->Disable(); m_calibration_btn->Disable();
m_options_btn->Disable(); m_options_btn->Disable();
m_panel_monitoring_title->Disable(); m_panel_monitoring_title->Disable();
m_media_play_ctrl->Disable();
} else if ((status & (int) MonitorStatus::MONITOR_NORMAL) != 0) { } else if ((status & (int) MonitorStatus::MONITOR_NORMAL) != 0) {
show_printing_status(true, true); show_printing_status(true, true);
m_calibration_btn->Disable(); m_calibration_btn->Disable();
m_options_btn->Enable(); m_options_btn->Enable();
m_panel_monitoring_title->Enable(); m_panel_monitoring_title->Enable();
m_media_play_ctrl->Enable();
} }
} }

View File

@ -1030,12 +1030,16 @@ void PresetUpdater::priv::sync_printer_config(std::string http_url)
auto cache_folder = data_dir_path / "ota" / "printers"; auto cache_folder = data_dir_path / "ota" / "printers";
try { try {
boost::filesystem::load_string_file(config_folder / "version.txt", curr_version); if (fs::exists(config_folder / "version.txt")) {
boost::algorithm::trim(curr_version); fs::load_string_file(config_folder / "version.txt", curr_version);
boost::algorithm::trim(curr_version);
}
} catch (...) {} } catch (...) {}
try { try {
boost::filesystem::load_string_file(cache_folder / "version.txt", cached_version); if (fs::exists(cache_folder / "version.txt")) {
boost::algorithm::trim(cached_version); fs::load_string_file(cache_folder / "version.txt", cached_version);
boost::algorithm::trim(cached_version);
}
} catch (...) {} } catch (...) {}
if (!cached_version.empty()) { if (!cached_version.empty()) {
bool need_delete_cache = false; bool need_delete_cache = false;
@ -1068,9 +1072,11 @@ void PresetUpdater::priv::sync_printer_config(std::string http_url)
bool result = false; bool result = false;
try { try {
boost::filesystem::load_string_file(cache_folder / "version.txt", cached_version); if (fs::exists(cache_folder / "version.txt")) {
boost::algorithm::trim(cached_version); fs::load_string_file(cache_folder / "version.txt", cached_version);
result = true; boost::algorithm::trim(cached_version);
result = true;
}
} catch (...) {} } catch (...) {}
if (result) { if (result) {
BOOST_LOG_TRIVIAL(info) << format("[BBL Updater] found new printer config: %1%, prompt to update", cached_version); BOOST_LOG_TRIVIAL(info) << format("[BBL Updater] found new printer config: %1%, prompt to update", cached_version);
@ -1187,12 +1193,16 @@ Updates PresetUpdater::priv::get_printer_config_updates(bool update) const
std::string curr_version; std::string curr_version;
std::string resc_version; std::string resc_version;
try { try {
boost::filesystem::load_string_file(resc_folder / "version.txt", resc_version); if (fs::exists(resc_folder / "version.txt")) {
boost::algorithm::trim(resc_version); fs::load_string_file(resc_folder / "version.txt", resc_version);
boost::algorithm::trim(resc_version);
}
} catch (...) {} } catch (...) {}
try { try {
boost::filesystem::load_string_file(config_folder / "version.txt", curr_version); if (fs::exists(config_folder / "version.txt")) {
boost::algorithm::trim(curr_version); fs::load_string_file(config_folder / "version.txt", curr_version);
boost::algorithm::trim(curr_version);
}
} catch (...) {} } catch (...) {}
if (!curr_version.empty()) { if (!curr_version.empty()) {