SendSystemInfo: Use /proc/info instead on lscpu on Linux,

center dialog after resizing
This commit is contained in:
Lukas Matena 2021-10-06 09:27:50 +02:00
parent 5946989c21
commit 56c3ea0261

View File

@ -36,7 +36,9 @@
#include <Iphlpapi.h> #include <Iphlpapi.h>
#pragma comment(lib, "iphlpapi.lib") #pragma comment(lib, "iphlpapi.lib")
#elif __APPLE__ #elif __APPLE__
#import <IOKit/IOKitLib.h> #import <IOKit/IOKitLib.h>
#else // Linux/BSD
#include <charconv>
#endif #endif
namespace Slic3r { namespace Slic3r {
@ -381,11 +383,15 @@ static std::string generate_system_info_json()
cpu_node.put("Model", sysctl["machdep.cpu.brand_string"]); cpu_node.put("Model", sysctl["machdep.cpu.brand_string"]);
cpu_node.put("Vendor", sysctl["machdep.cpu.vendor"]); cpu_node.put("Vendor", sysctl["machdep.cpu.vendor"]);
#else // linux/BSD #else // linux/BSD
std::map<std::string, std::string> lscpu = parse_lscpu_etc("lscpu", ':'); std::map<std::string, std::string> lscpu = parse_lscpu_etc("cat /proc/cpuinfo", ':');
cpu_node.put("Arch", lscpu["Architecture"]); if (auto ncpu_it = lscpu.find("processor"); ncpu_it != lscpu.end()) {
cpu_node.put("Cores", lscpu["CPU(s)"]); std::string& ncpu = ncpu_it->second;
cpu_node.put("Model", lscpu["Model name"]); if (int num=0; std::from_chars(ncpu.data(), ncpu.data() + ncpu.size(), num).ec != std::errc::invalid_argument)
cpu_node.put("Vendor", lscpu["Vendor ID"]); ncpu = std::to_string(num + 1);
}
cpu_node.put("Cores", lscpu["processor"]);
cpu_node.put("Model", lscpu["model name"]);
cpu_node.put("Vendor", lscpu["vendor_id"]);
#endif #endif
hw_node.add_child("CPU", cpu_node); hw_node.add_child("CPU", cpu_node);
@ -547,6 +553,7 @@ SendSystemInfoDialog::SendSystemInfoDialog(wxWindow* parent)
const auto size = GetSize(); const auto size = GetSize();
SetSize(std::max(size.GetWidth(), MIN_WIDTH * em), SetSize(std::max(size.GetWidth(), MIN_WIDTH * em),
std::max(size.GetHeight(), MIN_HEIGHT * em)); std::max(size.GetHeight(), MIN_HEIGHT * em));
CenterOnParent();
m_btn_send->Bind(wxEVT_BUTTON, [this](const wxEvent&) m_btn_send->Bind(wxEVT_BUTTON, [this](const wxEvent&)
{ {