History

getCPUBrand works on Mac

NissimHadar committed 7 years ago

Commit 9c00bdc1 parent bb543531 file · +14 −3Browse files

Showing the changes to interface/src/scripting/PlatformInfoScriptingInterface.cpp (1 of 1 file). Show all

Unified · Split

interface/src/scripting/PlatformInfoScriptingInterface.cpp+14−3
@@ -12,6 +12,8 @@ · 11 unmodified lines
1212
1313 #ifdef Q_OS_WIN
1414 #include <Windows.h>
15+#elif defined Q_OS_MAC
16+#include <sstream>
1517 #endif
1618
1719 PlatformInfoScriptingInterface* PlatformInfoScriptingInterface::getInstance() {
@@ -51,8 +53,17 @@ QString PlatformInfoScriptingInterface::getCPUBrand() { · 33 unmodified lines
5153 }
5254
5355 return CPUBrandString;
54−#else
55− return "NOT IMPLEMENTED";
56+#elif defined Q_OS_MAC
57+ FILE* stream = popen("sysctl -n machdep.cpu.brand_string", "r");
58+
59+ std::ostringstream hostStream;
60+ while (!feof(stream) && !ferror(stream)) {
61+ char buf[128];
62+ int bytesRead = fread(buf, 1, 128, stream);
63+ hostStream.write(buf, bytesRead);
64+ }
65+
66+ return QString::fromStdString(hostStream.str());
5667 #endif
5768 }
5869
@@ -74,4 +85,4 @@ int PlatformInfoScriptingInterface::getTotalSystemMemoryMB() { · 15 unmodified lines
7485
7586 QString PlatformInfoScriptingInterface::getGraphicsCardType() {
7687 return qApp->getGraphicsCardType();
77−}
88+}