Skip to content

Commit f28f83b

Browse files
committed
+ Show word size info of OS
1 parent e9ea1e2 commit f28f83b

File tree

1 file changed

+83
-3
lines changed

1 file changed

+83
-3
lines changed

src/Gui/Splashscreen.cpp

Lines changed: 83 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ AboutDialog::~AboutDialog()
235235
delete ui;
236236
}
237237

238+
class SystemInfo {
239+
public:
238240
static QString getOperatingSystem()
239241
{
240242
#if defined (Q_OS_WIN32)
@@ -278,6 +280,79 @@ static QString getOperatingSystem()
278280
#endif
279281
}
280282

283+
#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64)
284+
typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
285+
#endif
286+
static int getWordSizeOfOS()
287+
{
288+
#if defined(Q_OS_WIN64)
289+
return 64; // 64-bit process running on 64-bit windows
290+
#elif defined(Q_OS_WIN32)
291+
292+
// determine if 32-bit process running on 64-bit windows in WOW64 emulation
293+
// or 32-bit process running on 32-bit windows
294+
// default bIsWow64 to FALSE for 32-bit process on 32-bit windows
295+
296+
BOOL bIsWow64 = FALSE; // must default to FALSE
297+
298+
LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress(
299+
GetModuleHandle("kernel32"), "IsWow64Process");
300+
301+
if (NULL != fnIsWow64Process) {
302+
if (!fnIsWow64Process(GetCurrentProcess(), &bIsWow64)) {
303+
assert(false); // something went majorly wrong
304+
}
305+
}
306+
return bIsWow64 ? 64 : 32;
307+
308+
#elif defined (Q_OS_LINUX)
309+
// http://stackoverflow.com/questions/246007/how-to-determine-whether-a-given-linux-is-32-bit-or-64-bit
310+
QString exe(QLatin1String("getconf"));
311+
QStringList args;
312+
args << QLatin1String("LONG_BIT");
313+
QProcess proc;
314+
proc.setEnvironment(QProcess::systemEnvironment());
315+
proc.start(exe, args);
316+
if (proc.waitForStarted() && proc.waitForFinished()) {
317+
QByteArray info = proc.readAll();
318+
return info.toInt();
319+
}
320+
321+
return 0; // failed
322+
323+
#elif defined (Q_OS_UNIX) || defined (Q_OS_MAC)
324+
QString exe(QLatin1String("uname"));
325+
QStringList args;
326+
args << QLatin1String("-m");
327+
QProcess proc;
328+
proc.setEnvironment(QProcess::systemEnvironment());
329+
proc.start(exe, args);
330+
if (proc.waitForStarted() && proc.waitForFinished()) {
331+
QByteArray info = proc.readAll();
332+
info.replace('\n',"");
333+
if (info.indexOf("x86_64") >= 0)
334+
return 64;
335+
else if (info.indexOf("amd64") >= 0)
336+
return 64;
337+
else if (info.indexOf("ia64") >= 0)
338+
return 64;
339+
else if (info.indexOf("ppc64") >= 0)
340+
return 64;
341+
else if (info.indexOf("i386") >= 0)
342+
return 32;
343+
else if (info.indexOf("i686") >= 0)
344+
return 32;
345+
else if (info.indexOf("x86") >= 0)
346+
return 32;
347+
}
348+
349+
return 0; // failed
350+
#else
351+
return 0; // unknown
352+
#endif
353+
}
354+
};
355+
281356
void AboutDialog::setupLabels()
282357
{
283358
//fonts are rendered smaller on Mac so point size can't be the same for all platforms
@@ -320,7 +395,7 @@ void AboutDialog::setupLabels()
320395
ui->labelBuildDate->setText(date);
321396

322397
QString os = ui->labelBuildOS->text();
323-
os.replace(QString::fromAscii("Unknown"), getOperatingSystem());
398+
os.replace(QString::fromAscii("Unknown"), SystemInfo::getOperatingSystem());
324399
ui->labelBuildOS->setText(os);
325400

326401
QString platform = ui->labelBuildPlatform->text();
@@ -409,12 +484,17 @@ void AboutDialog::on_copyButton_clicked()
409484
QTextStream str(&data);
410485
std::map<std::string, std::string>& config = App::Application::Config();
411486
std::map<std::string,std::string>::iterator it;
487+
QString exe = QString::fromAscii(App::GetApplication().getExecutableName());
412488

413489
QString major = QString::fromAscii(config["BuildVersionMajor"].c_str());
414490
QString minor = QString::fromAscii(config["BuildVersionMinor"].c_str());
415491
QString build = QString::fromAscii(config["BuildRevision"].c_str());
416-
str << "OS: " << getOperatingSystem() << endl;
417-
str << "Word size: " << QSysInfo::WordSize << "-bit" << endl;
492+
str << "OS: " << SystemInfo::getOperatingSystem() << endl;
493+
int wordSize = SystemInfo::getWordSizeOfOS();
494+
if (wordSize > 0) {
495+
str << "Word size of OS: " << wordSize << "-bit" << endl;
496+
}
497+
str << "Word size of " << exe << ": " << QSysInfo::WordSize << "-bit" << endl;
418498
str << "Version: " << major << "." << minor << "." << build << endl;
419499
it = config.find("BuildRevisionBranch");
420500
if (it != config.end())

0 commit comments

Comments
 (0)