diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2018-11-04 15:28:37 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2018-11-04 14:46:01 +0100 |
commit | e128f7806961b391cfb265a1ce009b2e036622ca (patch) | |
tree | eda1097987f07ac6e2f507f898b71ddf929e0635 /toolkit/source/awt | |
parent | a2058e7516a01167c2d20ed157500b38db967c64 (diff) |
replace double-checked locking patterns with thread safe local statics
Change-Id: I1bf67196e97411aeecc13ed4f91d1088a315e323
Reviewed-on: https://gerrit.libreoffice.org/62839
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'toolkit/source/awt')
-rw-r--r-- | toolkit/source/awt/vclxmenu.cxx | 42 | ||||
-rw-r--r-- | toolkit/source/awt/vclxtoolkit.cxx | 26 |
2 files changed, 14 insertions, 54 deletions
diff --git a/toolkit/source/awt/vclxmenu.cxx b/toolkit/source/awt/vclxmenu.cxx index 02006e87de31..8782c77bb34c 100644 --- a/toolkit/source/awt/vclxmenu.cxx +++ b/toolkit/source/awt/vclxmenu.cxx @@ -237,43 +237,21 @@ css::uno::Sequence< css::uno::Type > VCLXMenu::getTypes() const bool bIsPopupMenu = IsPopupMenu(); aGuard.clear(); - static ::cppu::OTypeCollection* pCollectionMenuBar = nullptr; - static ::cppu::OTypeCollection* pCollectionPopupMenu = nullptr; - if ( bIsPopupMenu ) { - if( !pCollectionPopupMenu ) - { - ::osl::Guard< ::osl::Mutex > aGlobalGuard( ::osl::Mutex::getGlobalMutex() ); - if( !pCollectionPopupMenu ) - { - static ::cppu::OTypeCollection collectionPopupMenu( - cppu::UnoType<css::lang::XTypeProvider>::get(), - cppu::UnoType<css::awt::XMenu>::get(), - cppu::UnoType<css::awt::XPopupMenu>::get(), - cppu::UnoType<css::lang::XServiceInfo>::get()); - pCollectionPopupMenu = &collectionPopupMenu; - } - } - - return (*pCollectionPopupMenu).getTypes(); + static cppu::OTypeCollection collectionPopupMenu( + cppu::UnoType<css::lang::XTypeProvider>::get(), cppu::UnoType<css::awt::XMenu>::get(), + cppu::UnoType<css::awt::XPopupMenu>::get(), + cppu::UnoType<css::lang::XServiceInfo>::get()); + return collectionPopupMenu.getTypes(); } else { - if( !pCollectionMenuBar ) - { - ::osl::Guard< ::osl::Mutex > aGlobalGuard( ::osl::Mutex::getGlobalMutex() ); - if( !pCollectionMenuBar ) - { - static ::cppu::OTypeCollection collectionMenuBar( - cppu::UnoType<css::lang::XTypeProvider>::get(), - cppu::UnoType<css::awt::XMenu>::get(), - cppu::UnoType<css::awt::XMenuBar>::get(), - cppu::UnoType<css::lang::XServiceInfo>::get()); - pCollectionMenuBar = &collectionMenuBar; - } - } - return (*pCollectionMenuBar).getTypes(); + static cppu::OTypeCollection collectionMenuBar( + cppu::UnoType<css::lang::XTypeProvider>::get(), cppu::UnoType<css::awt::XMenu>::get(), + cppu::UnoType<css::awt::XMenuBar>::get(), + cppu::UnoType<css::lang::XServiceInfo>::get()); + return collectionMenuBar.getTypes(); } } diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx index 6ecb5cebbded..71a2be7b0e4b 100644 --- a/toolkit/source/awt/vclxtoolkit.cxx +++ b/toolkit/source/awt/vclxtoolkit.cxx @@ -838,32 +838,14 @@ static bool bInitedByVCLToolkit = false; osl::Mutex & getInitMutex() { - static osl::Mutex * pM; - if( !pM ) - { - osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); - if( !pM ) - { - static osl::Mutex aMutex; - pM = &aMutex; - } - } - return *pM; + static osl::Mutex aMutex; + return aMutex; } osl::Condition & getInitCondition() { - static osl::Condition * pC = nullptr; - if( !pC ) - { - osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); - if( !pC ) - { - static osl::Condition aCondition; - pC = &aCondition; - } - } - return *pC; + static osl::Condition aCondition; + return aCondition; } extern "C" |