From 6c4757505ac338eb8e995aacaf1d049957044725 Mon Sep 17 00:00:00 2001 From: "xin.zhang" Date: Thu, 3 Apr 2025 16:42:46 +0800 Subject: [PATCH] FIX: do something on machine lost jira: [STUDIO-11324] Change-Id: I915ebe84dfad00910df01e7f289109c602b02c1b --- src/slic3r/GUI/DeviceManager.cpp | 16 ++++++++++++++++ src/slic3r/GUI/DeviceManager.hpp | 3 +++ 2 files changed, 19 insertions(+) diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 5bf40f9fa..9a2157cc8 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -6918,6 +6918,10 @@ void DeviceManager::on_machine_alive(std::string json_str) it->second->dev_connection_type != connect_type || it->second->bind_ssdp_version != ssdp_version) { + if (it->second->bind_state != bind_state) { + OnMachineBindStateChanged(it->second, bind_state); + } + it->second->dev_ip = dev_ip; it->second->bind_state = bind_state; it->second->bind_sec_link = sec_link; @@ -7687,6 +7691,18 @@ std::string DeviceManager::get_filament_name_from_ams(int ams_id, int slot_id) return name; } +void DeviceManager::OnMachineBindStateChanged(MachineObject *obj, const std::string &new_state) { + if (!obj) { return; } + if (obj->dev_id == selected_machine) { + if (new_state == "free") { OnSelectedMachineLost();} + } +} + +void DeviceManager::OnSelectedMachineLost() { + GUI::wxGetApp().sidebar().update_sync_status(nullptr); + GUI::wxGetApp().sidebar().load_ams_list(string(), nullptr); +} + bool DeviceManager::check_filaments_printable(const std::string &tag_vendor, const std::string &tag_type, int ams_id, bool &in_blacklist, std::string &ac, std::string &info) { DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager(); diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index 47ed7c6de..c5687e315 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -1484,6 +1484,9 @@ public: static bool is_virtual_slot(int ams_id); static std::string get_filament_name_from_ams(int ams_id, int slot_id); +private: + void OnMachineBindStateChanged(MachineObject* obj, const std::string &new_state); + void OnSelectedMachineLost(); }; class DeviceManagerRefresher : public wxObject