From 2c1b0d6510a520b8211e217a81fd8f21f13c0194 Mon Sep 17 00:00:00 2001 From: "chunmao.guo" Date: Thu, 29 Feb 2024 10:46:36 +0800 Subject: [PATCH] FIX: PrinterFileSystem: retry connect on user action Change-Id: I3e8902298385ed2e5906fd15d1817b6e33522a76 Jira: STUDIO-6354 --- src/slic3r/GUI/MediaFilePanel.cpp | 14 +++++++++----- src/slic3r/GUI/MediaPlayCtrl.cpp | 3 ++- src/slic3r/GUI/Printer/PrinterFileSystem.cpp | 14 +++++++++----- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/slic3r/GUI/MediaFilePanel.cpp b/src/slic3r/GUI/MediaFilePanel.cpp index da3dbb85c..c39c54473 100644 --- a/src/slic3r/GUI/MediaFilePanel.cpp +++ b/src/slic3r/GUI/MediaFilePanel.cpp @@ -337,7 +337,9 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj) int result = e.GetExtraLong(); if (result > 1 && !e.GetString().IsEmpty()) - MessageDialog(this, e.GetString(), _L("Download failed"), wxOK | wxICON_ERROR).ShowModal(); + CallAfter([this, m = e.GetString()] { + MessageDialog(this, m, _L("Download failed"), wxOK | wxICON_ERROR).ShowModal(); + }); NetworkAgent* agent = wxGetApp().getAgent(); if (result > 1 || result == 0) { @@ -558,9 +560,11 @@ void MediaFilePanel::doAction(size_t index, int action) if (result == PrinterFileSystem::ERROR_CANCEL) return; if (result != 0) { - MessageDialog(this, - _L("Failed to fetch model information from printer."), - _L("Error"), wxOK).ShowModal(); + wxString msg = data.empty() ? _L("Failed to fetch model information from printer.") : + from_u8(data); + CallAfter([this, msg] { + MessageDialog(this, msg, _L("Print"), wxOK).ShowModal(); + }); return; } Slic3r::DynamicPrintConfig config; @@ -572,7 +576,7 @@ void MediaFilePanel::doAction(size_t index, int action) || plate_data_list.empty()) { MessageDialog(this, _L("Failed to parse model information."), - _L("Error"), wxOK).ShowModal(); + _L("Print"), wxOK).ShowModal(); return; } diff --git a/src/slic3r/GUI/MediaPlayCtrl.cpp b/src/slic3r/GUI/MediaPlayCtrl.cpp index e6712125f..9fd174e0a 100644 --- a/src/slic3r/GUI/MediaPlayCtrl.cpp +++ b/src/slic3r/GUI/MediaPlayCtrl.cpp @@ -315,7 +315,8 @@ void MediaPlayCtrl::Play() SetStatus(_L("Initializing...")); if (agent) { - agent->get_camera_url(m_machine, [this, m = m_machine, v = agent_version, dv = m_dev_ver](std::string url) { + agent->get_camera_url(m_machine, + [this, m = m_machine, v = agent_version, dv = m_dev_ver](std::string url) { if (boost::algorithm::starts_with(url, "bambu:///")) { url += "&device=" + into_u8(m); url += "&net_ver=" + v; diff --git a/src/slic3r/GUI/Printer/PrinterFileSystem.cpp b/src/slic3r/GUI/Printer/PrinterFileSystem.cpp index 70251a420..f2bb0842b 100644 --- a/src/slic3r/GUI/Printer/PrinterFileSystem.cpp +++ b/src/slic3r/GUI/Printer/PrinterFileSystem.cpp @@ -45,7 +45,7 @@ wxDEFINE_EVENT(EVT_FILE_CALLBACK, wxCommandEvent); static wxBitmap default_thumbnail; static std::map error_messages = { - {PrinterFileSystem::ERROR_PIPE, L("The printer has been logged out and cannot connect.")}, + {PrinterFileSystem::ERROR_PIPE, L("Reconnecting the printer, the operation cannot be completed immediately, please try again later.")}, {PrinterFileSystem::ERROR_RES_BUSY, L("Over 4 studio/handy are using remote access, you can close some and try again.")}, {PrinterFileSystem::FILE_NO_EXIST, L("File does not exist.")}, {PrinterFileSystem::FILE_CHECK_ERR, L("File checksum error. Please retry.")}, @@ -358,6 +358,13 @@ void PrinterFileSystem::FetchModel(size_t index, std::functionsecond.c_str()); + else + file_data->clear(); + } callback(result, *file_data); }); } @@ -1026,10 +1033,7 @@ void PrinterFileSystem::DumpLog(void * thiz, int, tchar const *msg) boost::uint32_t PrinterFileSystem::SendRequest(int type, json const &req, callback_t2 const &callback) { if (m_session.tunnel == nullptr) { - { - boost::unique_lock l(m_mutex); - m_cond.notify_all(); - } + Retry(); callback(ERROR_PIPE, json(), nullptr); return 0; }