From 8d115def760fb63f3731159b7a26fb1d56bf127b Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 7 Oct 2021 13:57:00 +0200 Subject: [PATCH] SendSystemInfo: Trim leading/trailing whitespace from all the values --- src/slic3r/GUI/SendSystemInfoDialog.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/slic3r/GUI/SendSystemInfoDialog.cpp b/src/slic3r/GUI/SendSystemInfoDialog.cpp index 7bdf1496d..908b52252 100644 --- a/src/slic3r/GUI/SendSystemInfoDialog.cpp +++ b/src/slic3r/GUI/SendSystemInfoDialog.cpp @@ -436,15 +436,23 @@ static std::string generate_system_info_json() pt::ptree root; root.add_child("data", data_node); + // Now go through all the values and trim leading/trailing whitespace. + // Some CPU names etc apparently have trailing spaces... + std::function remove_whitespace; + remove_whitespace = [&remove_whitespace](pt::ptree& t) -> void + { + if (t.empty()) // Trim whitespace + boost::algorithm::trim(t.data()); + else + for (auto it = t.begin(); it != t.end(); ++it) + remove_whitespace(it->second); + }; + remove_whitespace(root); + // Serialize the tree into JSON and return it. std::stringstream ss; pt::write_json(ss, root); return ss.str(); - - // FURTHER THINGS TO CONSIDER: - //std::cout << wxPlatformInfo::Get().GetOperatingSystemFamilyName() << std::endl; // Unix - // ? CPU, GPU, UNKNOWN ? - // printers? will they be installed already? }