From 0cd73f23f2ed3752b488e70f901c1bc43eceba2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Klitzing?= Date: Tue, 8 Dec 2015 09:08:31 +0100 Subject: [PATCH] Print correct OS name if it is a server version https://msdn.microsoft.com/en-us/library/windows/desktop/ms724833%28v=vs.85%29.aspx Change-Id: I7ee4c78959696ee2b662899a6a1408cfd1ebcacd Reviewed-by: Friedemann Kleint --- src/corelib/global/qglobal.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 3775cd421f..a8385d3174 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2104,6 +2104,8 @@ static QString winSp_helper() static const char *winVer_helper() { + const bool workstation = winOsVersion().wProductType == VER_NT_WORKSTATION; + switch (int(QSysInfo::WindowsVersion)) { case QSysInfo::WV_NT: return "NT"; @@ -2114,15 +2116,15 @@ static const char *winVer_helper() case QSysInfo::WV_2003: return "2003"; case QSysInfo::WV_VISTA: - return "Vista"; + return workstation ? "Vista" : "Server 2008"; case QSysInfo::WV_WINDOWS7: - return "7"; + return workstation ? "7" : "Server 2008 R2"; case QSysInfo::WV_WINDOWS8: - return "8"; + return workstation ? "8" : "Server 2012"; case QSysInfo::WV_WINDOWS8_1: - return "8.1"; + return workstation ? "8.1" : "Server 2012 R2"; case QSysInfo::WV_WINDOWS10: - return "10"; + return workstation ? "10" : "Server 2016"; case QSysInfo::WV_CE: return "CE"; @@ -2679,8 +2681,10 @@ QString QSysInfo::productVersion() return QString::number(version.major) + QLatin1Char('.') + QString::number(version.minor); #elif defined(Q_OS_WIN) const char *version = winVer_helper(); - if (version) - return QString::fromLatin1(version).toLower() + winSp_helper().remove(QLatin1Char(' ')).toLower(); + if (version) { + const QLatin1Char spaceChar(' '); + return QString::fromLatin1(version).remove(spaceChar).toLower() + winSp_helper().remove(spaceChar).toLower(); + } // fall through // Android should not fall through to the Unix code