Files
OrcaSlicer/src/slic3r/GUI/DeviceCore/DevFilaAmsSettingCtrl.cpp
T
Hanif Koh d8793f8353 Stop Leaking json Through Headers and Drop Includes Kept Only for the Name
AppConfig.hpp, DeviceManager.hpp and UserManager.hpp carried a global
"using namespace nlohmann;", json_diff.hpp a global "using json =
nlohmann::json;" and PrinterFileSystem.h a global "using nlohmann::json;".
Every file that included one of them, directly or not, could write a
bare json, and 63 did without declaring it.

The last two also made the include checker treat json_diff.hpp and
PrinterFileSystem.h as the headers that provide json, so they were
included from files that use nothing else from them: 57 of the 59
includers of json_diff.hpp never name json_diff.

The five statements are removed. Headers that use the type now spell
nlohmann::json, source files declare their own "using json =
nlohmann::json;", and the includes that only supplied the name are
dropped or replaced by <nlohmann/json.hpp>.

Eight files reached json_diff.hpp only through an include that is now
gone and with it lost that header's "using namespace std;". The std
names they used unqualified are qualified.
2026-10-07 01:39:17 +08:00

34 lines
979 B
C++

#include "DevFilaAmsSetting.h"
#include "DevFilaSystem.h"
#include <nlohmann/json.hpp>
#include "slic3r/GUI/DeviceManager.hpp"
#include <string>
#include "slic3r/GUI/DeviceCore/DevCtrl.h"
using json = nlohmann::json;
namespace Slic3r {
int DevAmsSystemFirmwareSwitch::CrtlSwitchFirmware(int firmware_idx)
{
if (!m_owner) {
return -1;
}
MachineObject* obj_ = m_owner->GetOwner();
json command_json;
command_json["upgrade"]["command"] = "mc_for_ams_firmware_upgrade";
command_json["upgrade"]["sequence_id"] = std::to_string(obj_->m_sequence_id++);
command_json["upgrade"]["src_id"] = 1;// 1-Studio
command_json["upgrade"]["id"] = firmware_idx;
int rtn = obj_->publish_json(command_json);
if (rtn == 0) {
m_status = "SWITCHING";
m_ctrl_switching = DevCtrlInfo(obj_, obj_->m_sequence_id - 1, command_json, 3, 1);
}
return rtn;
};
}