FIX: MediaFilePanel error state

Change-Id: I318ef59fb97478ffee16dff594022b2b9029964a
Jira: STUDIO-5638
This commit is contained in:
chunmao.guo 2023-12-19 18:41:34 +08:00 committed by Lane.Wei
parent dc47541220
commit a9227daca1
3 changed files with 9 additions and 7 deletions

View File

@ -27,6 +27,7 @@ MediaFilePanel::MediaFilePanel(wxWindow * parent)
, m_bmp_loading(this, "media_loading", 0)
, m_bmp_failed(this, "media_failed", 0)
, m_bmp_empty(this, "media_empty", 0)
, m_machine("<null>")
{
SetBackgroundColour(0xEEEEEE);
Hide();
@ -219,14 +220,14 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj)
m_model_download_support = false;
}
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 (machine == m_machine) {
if ((m_waiting_enable && IsEnabled()) || (m_waiting_support && (m_local_support || m_remote_support))) {
auto fs = m_image_grid->GetFileSystem();
if (fs) fs->Retry();
}
return;
}
m_machine = machine;
m_machine.swap(machine);
m_last_errors.clear();
auto fs = m_image_grid->GetFileSystem();
if (fs) {
@ -238,10 +239,6 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj)
SetSelecting(false);
if (m_machine.empty()) {
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) {
m_image_grid->SetStatus(m_bmp_failed, _L("Initialize failed (Not supported on the current printer version)!"));
} else {
boost::shared_ptr<PrinterFileSystem> fs(new PrinterFileSystem);
fs->Attached();
@ -431,10 +428,12 @@ void MediaFilePanel::fetchUrl(boost::weak_ptr<PrinterFileSystem> wfs)
}
m_waiting_enable = false;
if (!m_local_support && !m_remote_support) {
m_waiting_support = true;
m_image_grid->SetStatus(m_bmp_failed, _L("Initialize failed (Not supported on the current printer version)!"));
fs->SetUrl("0");
return;
}
m_waiting_support = false;
if ((m_lan_mode || !m_remote_support) && m_local_support && !m_lan_ip.empty()) {
std::string url = "bambu:///local/" + m_lan_ip + ".?port=6000&user=" + m_lan_user + "&passwd=" + m_lan_passwd +
"&device=" + m_machine + "&dev_ver=" + m_dev_ver;

View File

@ -87,6 +87,7 @@ private:
bool m_remote_support = false;
bool m_model_download_support = false;
bool m_waiting_enable = false;
bool m_waiting_support = false;
int m_last_mode = 0;
int m_last_type = 0;

View File

@ -1281,6 +1281,8 @@ void PrinterFileSystem::Reconnect(boost::unique_lock<boost::mutex> &l, int resul
if (url.size() < 2) {
wxLogMessage("PrinterFileSystem::Reconnect Initialize failed: %s", wxString::FromUTF8(url));
m_last_error = atoi(url.c_str());
if (m_last_error == 0)
m_stopped = true;
} else {
wxLogMessage("PrinterFileSystem::Reconnect Initialized: %s", Slic3r::GUI::hide_passwd(wxString::FromUTF8(url), {"authkey=", "passwd="}));
l.unlock();