summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYuhang Zhao <2546789017@qq.com>2021-11-02 12:44:34 +0800
committerYuhang Zhao <2546789017@qq.com>2021-11-02 12:40:26 +0000
commit3fe89eec61e2c819bb54a5d3dfe4bc29dba49ff3 (patch)
tree900ba8cef310e647d0cce3bed882e34e088c190b /src
parent059c48b908ff36c44dac0f8f0aacd970972ab871 (diff)
qoperatingsystemversion_win: cache the retrieved version
Make it a static variable to avoid acquiring the system version multiple times. The system version won't change at runtime after all. Pick-to: 6.2 Change-Id: Ic381e5dd7b482fedc9c01242482559ffca9d3f2b Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/global/qoperatingsystemversion_win.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/corelib/global/qoperatingsystemversion_win.cpp b/src/corelib/global/qoperatingsystemversion_win.cpp
index 37f2362d0c..e8c32be56b 100644
--- a/src/corelib/global/qoperatingsystemversion_win.cpp
+++ b/src/corelib/global/qoperatingsystemversion_win.cpp
@@ -110,12 +110,14 @@ OSVERSIONINFOEX qWindowsVersionInfo()
QOperatingSystemVersion QOperatingSystemVersion::current()
{
- QOperatingSystemVersion v;
- v.m_os = currentType();
- const OSVERSIONINFOEX osv = qWindowsVersionInfo();
- v.m_major = osv.dwMajorVersion;
- v.m_minor = osv.dwMinorVersion;
- v.m_micro = osv.dwBuildNumber;
+ static QOperatingSystemVersion v;
+ if (v.m_os == Unknown) {
+ v.m_os = currentType();
+ const OSVERSIONINFOEX osv = qWindowsVersionInfo();
+ v.m_major = osv.dwMajorVersion;
+ v.m_minor = osv.dwMinorVersion;
+ v.m_micro = osv.dwBuildNumber;
+ }
return v;
}