summaryrefslogtreecommitdiff
path: root/vcl/opengl/win
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-11-20 13:09:09 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-11-23 13:35:25 +0100
commit70894bcdb3912dbe87031da0af9ae5d591275e2a (patch)
treeca424232691a12bfca34293b093a7d9bd21525e9 /vcl/opengl/win
parent0c8b936734285ee7f373c41ecbad5a65953789dc (diff)
improve function local statics
simplify the initialisaion and make them thread-safe i.e. initialise them using the runtime's local static locking. Thanks to mike kaganski for pointing out the nice lambda approach that makes this feasible. Change-Id: I76391189a6d0a3d7eed2d0d88d28dfa6541eaff7 Reviewed-on: https://gerrit.libreoffice.org/63645 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl/opengl/win')
-rw-r--r--vcl/opengl/win/WinDeviceInfo.cxx9
1 files changed, 4 insertions, 5 deletions
diff --git a/vcl/opengl/win/WinDeviceInfo.cxx b/vcl/opengl/win/WinDeviceInfo.cxx
index 9c48651918a5..2ebccf9ee6f4 100644
--- a/vcl/opengl/win/WinDeviceInfo.cxx
+++ b/vcl/opengl/win/WinDeviceInfo.cxx
@@ -190,9 +190,7 @@ wgl::OperatingSystem WindowsVersionToOperatingSystem(int32_t aWindowsVersion)
int32_t WindowsOSVersion()
{
- static int32_t winVersion = kWindowsUnknown;
-
- if (winVersion == kWindowsUnknown)
+ static int32_t winVersion = [&]()
{
// GetVersion(Ex) and VersionHelpers (based on VerifyVersionInfo) API are
// subject to manifest-based behavior since Windows 8.1, so give wrong results.
@@ -219,13 +217,14 @@ int32_t WindowsOSVersion()
if (VerQueryValueW(ver.get(), L"\\", &pBlock, &dwBlockSz) != FALSE && dwBlockSz >= sizeof(VS_FIXEDFILEINFO))
{
VS_FIXEDFILEINFO *vinfo = static_cast<VS_FIXEDFILEINFO *>(pBlock);
- winVersion = int32_t(vinfo->dwProductVersionMS);
+ return int32_t(vinfo->dwProductVersionMS);
}
}
}
}
}
- }
+ return int32_t(kWindowsUnknown);
+ }();
return winVersion;
}