[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - shell/source
Mike Kaganski (via logerrit)
logerrit at kemper.freedesktop.org
Thu Jun 20 04:23:08 UTC 2019
shell/source/win32/spsupp/spsuppServ.cxx | 30 ++++++++++++++----------------
1 file changed, 14 insertions(+), 16 deletions(-)
New commits:
commit 00c65b6e2129cfccb1ff909ea88fe64e6c5f6f5b
Author: Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Wed May 15 08:31:44 2019 +0200
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Thu Jun 20 06:22:21 2019 +0200
Use lambdas to initialize statics
Change-Id: Ib03bfd795967ba70333d71d9e5eeec97be90be79
Reviewed-on: https://gerrit.libreoffice.org/72334
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
(cherry picked from commit a11536d5ea695826844581c8c8f883970e0c8294)
Reviewed-on: https://gerrit.libreoffice.org/74402
Tested-by: Mike Kaganski <mike.kaganski at collabora.com>
diff --git a/shell/source/win32/spsupp/spsuppServ.cxx b/shell/source/win32/spsupp/spsuppServ.cxx
index 78af725bec60..f15f505fd730 100644
--- a/shell/source/win32/spsupp/spsuppServ.cxx
+++ b/shell/source/win32/spsupp/spsuppServ.cxx
@@ -37,35 +37,33 @@ HANDLE g_hModule;
ITypeLib* GetTypeLib()
{
typedef std::unique_ptr<ITypeLib, void(*)(IUnknown* p)> ITypeLibGuard;
- static ITypeLibGuard aITypeLibGuard(nullptr, [](IUnknown* p) { if (p) p->Release(); });
- if (!aITypeLibGuard.get())
- {
+ static ITypeLibGuard s_aITypeLibGuard = [] {
+ ITypeLibGuard aITypeLibGuard(nullptr, [](IUnknown* p) { if (p) p->Release(); });
wchar_t szFile[MAX_PATH];
if (GetModuleFileNameW(static_cast<HMODULE>(g_hModule), szFile, MAX_PATH) == 0)
- return nullptr;
+ return aITypeLibGuard;
ITypeLib* pTypeLib;
- HRESULT hr = LoadTypeLib(szFile, &pTypeLib);
- if (FAILED(hr))
- return nullptr;
+ if (FAILED(LoadTypeLib(szFile, &pTypeLib)))
+ return aITypeLibGuard;
aITypeLibGuard.reset(pTypeLib);
- }
- return aITypeLibGuard.get();
+ return aITypeLibGuard;
+ }();
+ return s_aITypeLibGuard.get();
}
const wchar_t* GetLOPath()
{
- static wchar_t sPath[MAX_PATH] = { 0 };
- if (*sPath == 0)
- {
- // Initialization
+ static wchar_t* s_sPath = []() -> wchar_t* {
+ static wchar_t sPath[MAX_PATH];
if (GetModuleFileNameW(static_cast<HMODULE>(g_hModule), sPath, MAX_PATH) == 0)
return nullptr;
wchar_t* pSlashPos = wcsrchr(sPath, L'\\');
if (pSlashPos == nullptr)
return nullptr;
- wcscpy(pSlashPos+1, L"soffice.exe");
- }
- return sPath;
+ wcscpy(pSlashPos + 1, L"soffice.exe");
+ return sPath;
+ }();
+ return s_sPath;
}
BOOL APIENTRY DllMain( HANDLE hinstDLL,
More information about the Libreoffice-commits
mailing list