From 6fdf697bc7cdd773b621851fec6fe913d0ca3e64 Mon Sep 17 00:00:00 2001 From: Lam Wei Lun Date: Mon, 21 Sep 2026 18:15:29 +0800 Subject: [PATCH] Safety checks for GUI --- src/slic3r/GUI/Plater.cpp | 4 +++- src/slic3r/GUI/Plater.hpp | 3 ++- src/slic3r/Utils/OrcaPrinterAgent.cpp | 12 +++++++----- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 85002c2b6c..b9e20cd5ec 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -5913,7 +5913,7 @@ void Sidebar::sync_ams_list(bool is_from_big_sync_btn) auto & list = wxGetApp().preset_bundle->filament_ams_list; if (list.empty()) { auto printer_name = p->plater->get_selected_printer_name_in_combox(); - p->plater->pop_warning_and_go_to_device_page(printer_name, Plater::PrinterWarningType::NOT_CONNECTED, _L("Sync printer information")); + p->plater->pop_warning_and_go_to_device_page(printer_name, Plater::PrinterWarningType::AMS_UNAVAILABLE, _L("Sync printer information")); return; } bool exist_at_list_one_filament =false; @@ -20930,6 +20930,8 @@ void Plater::pop_warning_and_go_to_device_page(wxString printer_name, PrinterWar content = _L("There are no filaments on the printer. Please load the filaments on the printer first."); } else if (type == PrinterWarningType::EMPTY_FILAMENT) { content = _L("The filaments on the printer are all unknown types. Please go to the printer screen or software device page to set the filament type."); + } else if (type == PrinterWarningType::AMS_UNAVAILABLE) { + content = _L("No AMS filament data is available for this printer. Make sure the printer's material system is detected and connected, then try again."); } MessageDialog dlg(this, content, title, wxOK | wxFORWARD | wxICON_WARNING, _L("Device Page")); auto result = dlg.ShowModal(); diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index e9cb45d22d..c37ef47b89 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -637,7 +637,8 @@ public: NOT_CONNECTED, INCONSISTENT, UNINSTALL_FILAMENT, - EMPTY_FILAMENT + EMPTY_FILAMENT, + AMS_UNAVAILABLE }; void pop_warning_and_go_to_device_page(wxString printer_name, PrinterWarningType type, const wxString &title); bool check_printer_initialized(MachineObject *obj, bool only_warning = false,bool popup_warning = true); diff --git a/src/slic3r/Utils/OrcaPrinterAgent.cpp b/src/slic3r/Utils/OrcaPrinterAgent.cpp index 24c01a5cb6..8466e58b42 100644 --- a/src/slic3r/Utils/OrcaPrinterAgent.cpp +++ b/src/slic3r/Utils/OrcaPrinterAgent.cpp @@ -943,7 +943,6 @@ OrcaPrinterAgent::LaneDataState OrcaPrinterAgent::fetch_lane_data(const std::str std::string response_body; unsigned http_status = 0; - bool transport_error = false; std::string http_error; auto http = Http::get(url); if (!api_key.empty()) @@ -959,15 +958,18 @@ OrcaPrinterAgent::LaneDataState OrcaPrinterAgent::fetch_lane_data(const std::str } }) .on_error([&](std::string, std::string err, unsigned status) { - transport_error = true; - http_status = status; - http_error = err; + http_status = status; + http_error = err; if (status > 0) http_error += " (HTTP " + std::to_string(status) + ")"; }) .perform_sync(); - if (http_status == 404 && !transport_error) { + // Http routes every >=400 response through on_error(), so a 404 arrives here + // with an empty err and the status in http_status. It is a real HTTP + // response, not a transport failure: the namespace is not served / topology + // unknown (REQ-STS-007 ยง7.7). Never latch a retry for it. + if (http_status == 404) { BOOST_LOG_TRIVIAL(info) << "OrcaPrinterAgent::fetch_lane_data: lane_data not served yet (unknown topology)"; return LaneDataState::unknown; }