diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-04-02 15:12:00 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-04-02 17:22:21 +0200 |
commit | 86d298f87f00fe70d31a65b7e98f9b17fa80cb6b (patch) | |
tree | 0b7a389105ead641d092e56ff6fb1d49180f6265 /sfx2 | |
parent | 711ec7b6c71410b850cdf6d1411d054ca34ec5a0 (diff) |
Simplify some static variable initializations
Change-Id: I6cdd44aa66b9597ccc51fc3fd69b57485ccb3230
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113515
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/appl/appinit.cxx | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/sfx2/source/appl/appinit.cxx b/sfx2/source/appl/appinit.cxx index fbecd9d66b61..97b85ef84a92 100644 --- a/sfx2/source/appl/appinit.cxx +++ b/sfx2/source/appl/appinit.cxx @@ -147,30 +147,28 @@ extern "C" bool GetSpecialCharsForEdit(weld::Widget* i_pParent, const vcl::Font& static OUString SfxGetSpecialCharsForEdit(weld::Widget* pParent, const vcl::Font& rFont) { - static bool bDetermineFunction = false; - static PFunc_getSpecialCharsForEdit pfunc_getSpecialCharsForEdit = nullptr; - - SolarMutexGuard aGuard; - if ( !bDetermineFunction ) - { - bDetermineFunction = true; - + static const PFunc_getSpecialCharsForEdit pfunc_getSpecialCharsForEdit = [] { + PFunc_getSpecialCharsForEdit pfunc = nullptr; #ifndef DISABLE_DYNLOADING osl::Module aMod; aMod.loadRelative(&thisModule, SVLIBRARY("cui")); // get symbol - pfunc_getSpecialCharsForEdit = reinterpret_cast<PFunc_getSpecialCharsForEdit>(aMod.getFunctionSymbol("GetSpecialCharsForEdit")); - DBG_ASSERT( pfunc_getSpecialCharsForEdit, "GetSpecialCharsForEdit() not found!" ); + pfunc = reinterpret_cast<PFunc_getSpecialCharsForEdit>(aMod.getFunctionSymbol("GetSpecialCharsForEdit")); + DBG_ASSERT( pfunc, "GetSpecialCharsForEdit() not found!" ); aMod.release(); #else - pfunc_getSpecialCharsForEdit = GetSpecialCharsForEdit; + pfunc = GetSpecialCharsForEdit; #endif - } + return pfunc; + }(); OUString aRet; if ( pfunc_getSpecialCharsForEdit ) + { + SolarMutexGuard aGuard; (*pfunc_getSpecialCharsForEdit)( pParent, rFont, aRet ); + } return aRet; } |