diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2018-11-04 03:12:18 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2018-11-04 18:03:09 +0100 |
commit | 41707751a60a8044d49896b0e62d9fe0e997af85 (patch) | |
tree | afaa7252c07aeca7eaf91df5cac70a214245daa0 /sfx2 | |
parent | a786fad56fa48f7d01c6504e7063c57178d7fb64 (diff) |
tdf#120703 PVS: V547 Get rid of mutexes to initialize function-local statics
Also fix an infinite recursion when VCLXHatchWindow::getTypes() called
VCLXHatchWindow::getTypes() when initializing its static.
Change-Id: I19b8b1e1b367ddf636f905fb141c7690e21f67f8
Reviewed-on: https://gerrit.libreoffice.org/62825
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/dialog/backingcomp.cxx | 51 |
1 files changed, 19 insertions, 32 deletions
diff --git a/sfx2/source/dialog/backingcomp.cxx b/sfx2/source/dialog/backingcomp.cxx index d6e36f75476b..015ce31b71a7 100644 --- a/sfx2/source/dialog/backingcomp.cxx +++ b/sfx2/source/dialog/backingcomp.cxx @@ -235,38 +235,25 @@ void SAL_CALL BackingComp::release() css::uno::Sequence< css::uno::Type > SAL_CALL BackingComp::getTypes() { - static ::cppu::OTypeCollection* pTypeCollection = nullptr; - if (!pTypeCollection) - { - /* GLOBAL SAFE { */ - ::osl::MutexGuard aGlobalLock(m_aTypeProviderMutex); - // Control these pointer again ... it can be, that another instance will be faster then this one! - if (!pTypeCollection) - { - /* LOCAL SAFE { */ - SolarMutexGuard aGuard; - css::uno::Reference< css::lang::XTypeProvider > xProvider(m_xWindow, css::uno::UNO_QUERY); - - css::uno::Sequence< css::uno::Type > lWindowTypes; - if (xProvider.is()) - lWindowTypes = xProvider->getTypes(); - - static ::cppu::OTypeCollection aTypeCollection( - cppu::UnoType<css::lang::XInitialization>::get(), - cppu::UnoType<css::lang::XTypeProvider>::get(), - cppu::UnoType<css::lang::XServiceInfo>::get(), - cppu::UnoType<css::frame::XController>::get(), - cppu::UnoType<css::lang::XComponent>::get(), - cppu::UnoType<css::frame::XDispatchProvider>::get(), - cppu::UnoType<css::frame::XDispatch>::get(), - lWindowTypes); - - pTypeCollection = &aTypeCollection; - /* } LOCAL SAFE */ - } - /* } GLOBAL SAFE */ - } - return pTypeCollection->getTypes(); + static cppu::OTypeCollection aTypeCollection = [this]() { + SolarMutexGuard aGuard; + css::uno::Reference<css::lang::XTypeProvider> xProvider(m_xWindow, css::uno::UNO_QUERY); + + css::uno::Sequence<css::uno::Type> lWindowTypes; + if (xProvider.is()) + lWindowTypes = xProvider->getTypes(); + + return cppu::OTypeCollection( + cppu::UnoType<css::lang::XInitialization>::get(), + cppu::UnoType<css::lang::XTypeProvider>::get(), + cppu::UnoType<css::lang::XServiceInfo>::get(), + cppu::UnoType<css::frame::XController>::get(), + cppu::UnoType<css::lang::XComponent>::get(), + cppu::UnoType<css::frame::XDispatchProvider>::get(), + cppu::UnoType<css::frame::XDispatch>::get(), lWindowTypes); + }(); + + return aTypeCollection.getTypes(); } |