diff options
author | Yuhang Zhao <2546789017@qq.com> | 2022-05-20 14:07:54 +0800 |
---|---|---|
committer | Yuhang Zhao <2546789017@qq.com> | 2022-05-26 09:26:10 +0800 |
commit | 182ac2ced4d1607308a9bae2f2720215e015494c (patch) | |
tree | b7d531dd1f836270625b0c5ff83948a1132cf6fb /src/corelib/global/qglobal.cpp | |
parent | f4b7401cdb809f02c56ac739ae0507c7427ae196 (diff) |
Fix Windows display version
The "ReleaseId" key's value stopped updating since
Windows 10 20H2, so we should query the new "DisplayVersion"
key when running on Windows 10 20H2 and onwards.
Change-Id: Ifaa8287f9812126bde0390337af0cda23ff8e529
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/global/qglobal.cpp')
-rw-r--r-- | src/corelib/global/qglobal.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index cd78dfde1a..738e39658f 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2157,9 +2157,14 @@ static QString readVersionRegistryString(const wchar_t *subKey) .stringValue(subKey); } -static inline QString windows10ReleaseId() +static inline QString windowsDisplayVersion() { - return readVersionRegistryString(L"ReleaseId"); + // https://tickets.puppetlabs.com/browse/FACT-3058 + // The "ReleaseId" key stopped updating since Windows 10 20H2. + if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows10_20H2) + return readVersionRegistryString(L"DisplayVersion"); + else + return readVersionRegistryString(L"ReleaseId"); } static QString winSp_helper() @@ -2880,9 +2885,9 @@ QString QSysInfo::prettyProductName() return result + " ("_L1 + versionString + u')'; # else // (resembling winver.exe): Windows 10 "Windows 10 Version 1809" - const auto releaseId = windows10ReleaseId(); - if (!releaseId.isEmpty()) - result += " Version "_L1 + releaseId; + const auto displayVersion = windowsDisplayVersion(); + if (!displayVersion.isEmpty()) + result += " Version "_L1 + displayVersion; return result; # endif // Windows #elif defined(Q_OS_HAIKU) |