Stop Leaking json Through Headers and Drop Includes Kept Only for the Name (#16221)

* 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.

* Declare json in OrcaSlicer.cpp on Every Platform

OrcaSlicer.cpp had its "using namespace nlohmann;" and the json include
inside the Linux-only include block, so on Windows and macOS it took
json from AppConfig.hpp's global directive, which is gone. The include
and a "using json = nlohmann::json;" now sit outside the block.
This commit is contained in:
HanifKoh
2026-10-07 14:22:16 +08:00
committed by GitHub
parent 78f74a6276
commit 73d32d4791
92 changed files with 215 additions and 175 deletions
+2 -2
View File
@@ -453,7 +453,7 @@ wxBitmap create_scaled_bitmap( const std::string& bmp_name_in,
const bool menu_bitmap/* = false*/,
const bool resize/* = false*/,
const bool bitmap2/* = false*/,
const vector<std::string>& array_new_color/* = vector<std::string>*/)//used for semi transparent material)
const std::vector<std::string>& array_new_color/* = vector<std::string>*/)//used for semi transparent material)
{
static Slic3r::GUI::BitmapCache cache;
@@ -501,7 +501,7 @@ wxBitmap create_scaled_bitmap( const std::string& bmp_name_in,
wxBitmap create_scaled_bitmap2(const std::string& bmp_name_in, Slic3r::GUI::BitmapCache& cache, wxWindow* win/* = nullptr*/ ,
const int px_cnt/* = 16*/, const bool grayscale/* = false*/ , const bool resize/* = false*/ ,
const vector<std::string>& array_new_color/* = vector<std::string>()*/) // color witch will used instead of orange
const std::vector<std::string>& array_new_color/* = vector<std::string>()*/) // color witch will used instead of orange
{
unsigned int width = 0;
// win may be nullptr; see create_scaled_bitmap() above.