Skip to content

Commit

Permalink
qoperatingsystemversion_win: cache the retrieved version
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
wangwenx190 committed Nov 2, 2021
1 parent 059c48b commit 3fe89ee
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/corelib/global/qoperatingsystemversion_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 3fe89ee

Please sign in to comment.