From 6b16793cd13e540c1dfc1686df948c0dbcbe8068 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Sat, 18 Dec 2021 09:20:08 +0200 Subject: [PATCH] use more cppu::BaseMutex Change-Id: I1ee9aff2774a673666c332c116aa5b0ba0d8b585 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127077 Tested-by: Jenkins Reviewed-by: Noel Grandin --- stoc/source/servicemanager/servicemanager.cxx | 63 +++++++++---------- svx/source/inc/gridcell.hxx | 10 +-- svx/source/unodraw/unoshcol.cxx | 13 ++-- toolkit/source/awt/vclxtoolkit.cxx | 11 +--- 4 files changed, 39 insertions(+), 58 deletions(-) diff --git a/stoc/source/servicemanager/servicemanager.cxx b/stoc/source/servicemanager/servicemanager.cxx index 5fb5b3962495..ddaee87576d8 100644 --- a/stoc/source/servicemanager/servicemanager.cxx +++ b/stoc/source/servicemanager/servicemanager.cxx @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -300,10 +301,6 @@ void OServiceManager_Listener::disposing(const EventObject & rEvt ) /***************************************************************************** class OServiceManager *****************************************************************************/ -struct OServiceManagerMutex -{ - Mutex m_mutex; -}; typedef WeakComponentImplHelper< lang::XMultiServiceFactory, lang::XMultiComponentFactory, lang::XServiceInfo, @@ -312,7 +309,7 @@ typedef WeakComponentImplHelper< beans::XPropertySet > t_OServiceManager_impl; class OServiceManager - : public OServiceManagerMutex + : public cppu::BaseMutex , public t_OServiceManager_impl { public: @@ -426,7 +423,7 @@ typedef WeakComponentImplHelper< container::XSet, container::XContentEnumerationAccess, beans::XPropertySet > t_OServiceManagerWrapper_impl; -class OServiceManagerWrapper : public OServiceManagerMutex, public t_OServiceManagerWrapper_impl +class OServiceManagerWrapper : public cppu::BaseMutex, public t_OServiceManagerWrapper_impl { Reference< XComponentContext > m_xContext; Reference< XMultiComponentFactory > m_root; @@ -528,7 +525,7 @@ void SAL_CALL OServiceManagerWrapper::setPropertyValue( static_cast(this), 1 ); } - MutexGuard aGuard( m_mutex ); + MutexGuard aGuard( m_aMutex ); m_xContext = xContext; } @@ -543,7 +540,7 @@ Any SAL_CALL OServiceManagerWrapper::getPropertyValue( { if ( PropertyName == "DefaultContext" ) { - MutexGuard aGuard( m_mutex ); + MutexGuard aGuard( m_aMutex ); if( m_xContext.is() ) return makeAny( m_xContext ); else @@ -565,7 +562,7 @@ void OServiceManagerWrapper::disposing() OServiceManagerWrapper::OServiceManagerWrapper( Reference< XComponentContext > const & xContext ) - : t_OServiceManagerWrapper_impl( m_mutex ) + : t_OServiceManagerWrapper_impl( m_aMutex ) , m_xContext( xContext ) , m_root( xContext->getServiceManager() ) { @@ -581,7 +578,7 @@ OServiceManagerWrapper::OServiceManagerWrapper( * Create a ServiceManager */ OServiceManager::OServiceManager( Reference< XComponentContext > const & xContext ) - : t_OServiceManager_impl( m_mutex ) + : t_OServiceManager_impl( m_aMutex ) , m_xContext( xContext ) , m_bInDisposing( false ) {} @@ -599,7 +596,7 @@ void OServiceManager::disposing() // dispose all factories HashSet_Ref aImpls; { - MutexGuard aGuard( m_mutex ); + MutexGuard aGuard( m_aMutex ); m_bInDisposing = true; aImpls = m_ImplementationMap; } @@ -620,7 +617,7 @@ void OServiceManager::disposing() // dispose HashSet_Ref aImplMap; { - MutexGuard aGuard( m_mutex ); + MutexGuard aGuard( m_aMutex ); // erase all members m_ServiceMap = HashMultimap_OWString_Interface(); aImplMap = m_ImplementationMap; @@ -645,7 +642,7 @@ Reference OServiceManager::getPropertySetInfo() "DefaultContext", -1, cppu::UnoType::get(), 0 ) }; Reference< beans::XPropertySetInfo > xInfo( new PropertySetInfo_Impl( seq ) ); - MutexGuard aGuard( m_mutex ); + MutexGuard aGuard( m_aMutex ); if (! m_xPropertyInfo.is()) { m_xPropertyInfo = xInfo; @@ -673,7 +670,7 @@ void OServiceManager::setPropertyValue( static_cast(this), 1 ); } - MutexGuard aGuard( m_mutex ); + MutexGuard aGuard( m_aMutex ); m_xContext = xContext; } @@ -682,7 +679,7 @@ Any OServiceManager::getPropertyValue(const OUString& PropertyName) check_undisposed(); if ( PropertyName == "DefaultContext" ) { - MutexGuard aGuard( m_mutex ); + MutexGuard aGuard( m_aMutex ); if( m_xContext.is() ) return makeAny( m_xContext ); else @@ -728,7 +725,7 @@ void OServiceManager::removeVetoableChangeListener( Reference OServiceManager::getFactoryListener() { check_undisposed(); - MutexGuard aGuard( m_mutex ); + MutexGuard aGuard( m_aMutex ); if( !xFactoryListener.is() ) xFactoryListener = new OServiceManager_Listener( this ); return xFactoryListener; @@ -739,7 +736,7 @@ Sequence< OUString > OServiceManager::getUniqueAvailableServiceNames( HashSet_OWString & aNameSet ) { check_undisposed(); - MutexGuard aGuard( m_mutex ); + MutexGuard aGuard( m_aMutex ); for( const auto& rEntry : m_ServiceMap ) aNameSet.insert( rEntry.first ); @@ -914,7 +911,7 @@ Sequence< Reference< XInterface > > OServiceManager::queryServiceFactories( { Sequence< Reference< XInterface > > ret; - MutexGuard aGuard( m_mutex ); + MutexGuard aGuard( m_aMutex ); ::std::pair< HashMultimap_OWString_Interface::iterator, HashMultimap_OWString_Interface::iterator> p( @@ -963,7 +960,7 @@ Reference OServiceManager::createContentEnumeration( Reference OServiceManager::createEnumeration() { check_undisposed(); - MutexGuard aGuard( m_mutex ); + MutexGuard aGuard( m_aMutex ); return new ImplementationEnumeration_Impl( m_ImplementationMap ); } @@ -978,7 +975,7 @@ Type OServiceManager::getElementType() sal_Bool OServiceManager::hasElements() { check_undisposed(); - MutexGuard aGuard( m_mutex ); + MutexGuard aGuard( m_aMutex ); return !m_ImplementationMap.empty(); } @@ -989,13 +986,13 @@ sal_Bool OServiceManager::has( const Any & Element ) if( Element.getValueTypeClass() == TypeClass_INTERFACE ) { Reference xEle( Element, UNO_QUERY_THROW ); - MutexGuard aGuard( m_mutex ); + MutexGuard aGuard( m_aMutex ); return m_ImplementationMap.find( xEle ) != m_ImplementationMap.end(); } else if (auto implName = o3tl::tryAccess(Element)) { - MutexGuard aGuard( m_mutex ); + MutexGuard aGuard( m_aMutex ); return m_ImplementationNameMap.find( *implName ) != m_ImplementationNameMap.end(); } @@ -1015,7 +1012,7 @@ void OServiceManager::insert( const Any & Element ) Reference xEle( Element, UNO_QUERY_THROW ); { - MutexGuard aGuard( m_mutex ); + MutexGuard aGuard( m_aMutex ); HashSet_Ref::iterator aIt = m_ImplementationMap.find( xEle ); if( aIt != m_ImplementationMap.end() ) { @@ -1067,7 +1064,7 @@ void OServiceManager::remove( const Any & Element ) } else if (auto implName = o3tl::tryAccess(Element)) { - MutexGuard aGuard( m_mutex ); + MutexGuard aGuard( m_aMutex ); HashMap_OWString_Interface::const_iterator const iFind( m_ImplementationNameMap.find( *implName ) ); if (iFind == m_ImplementationNameMap.end()) @@ -1090,7 +1087,7 @@ void OServiceManager::remove( const Any & Element ) if( xComp.is() ) xComp->removeEventListener( getFactoryListener() ); - MutexGuard aGuard( m_mutex ); + MutexGuard aGuard( m_aMutex ); HashSet_Ref::iterator aIt = m_ImplementationMap.find( xEle ); if( aIt == m_ImplementationMap.end() ) { @@ -1208,7 +1205,7 @@ void ORegistryServiceManager::dispose() return; OServiceManager::dispose(); // dispose - MutexGuard aGuard( m_mutex ); + MutexGuard aGuard( m_aMutex ); // erase all members m_xRegistry.clear(); m_xRootKey.clear(); @@ -1224,7 +1221,7 @@ Reference ORegistryServiceManager::getRootKey() { if( !m_xRootKey.is() ) { - MutexGuard aGuard( m_mutex ); + MutexGuard aGuard( m_aMutex ); // DefaultRegistry suchen !!!! if( !m_xRegistry.is() && !m_searchedRegistry ) { @@ -1341,7 +1338,7 @@ void ORegistryServiceManager::fillAllNamesFromRegistry( HashSet_OWString & rSet void ORegistryServiceManager::initialize(const Sequence< Any >& Arguments) { check_undisposed(); - MutexGuard aGuard( m_mutex ); + MutexGuard aGuard( m_aMutex ); if (Arguments.hasElements()) { m_xRootKey.clear(); @@ -1358,7 +1355,7 @@ void ORegistryServiceManager::initialize(const Sequence< Any >& Arguments) Sequence< OUString > ORegistryServiceManager::getAvailableServiceNames() { check_undisposed(); - MutexGuard aGuard( m_mutex ); + MutexGuard aGuard( m_aMutex ); // all names HashSet_OWString aNameSet; @@ -1387,7 +1384,7 @@ Sequence< Reference< XInterface > > ORegistryServiceManager::queryServiceFactori } else { - MutexGuard aGuard( m_mutex ); + MutexGuard aGuard( m_aMutex ); Reference< XInterface > x( loadWithServiceName( aServiceName, xContext ) ); if (! x.is()) x = loadWithImplementationName( aServiceName, xContext ); @@ -1400,7 +1397,7 @@ Reference ORegistryServiceManager::createContentEnumeration( const OUString& aServiceName ) { check_undisposed(); - MutexGuard aGuard(m_mutex); + MutexGuard aGuard(m_aMutex); // get all implementation names registered under this service name from the registry const Sequence aImpls = getFromServiceName( aServiceName ); // load and insert all factories specified by the registry @@ -1428,7 +1425,7 @@ Reference ORegistryServiceManager::getPropertySetInfo() }; Reference< beans::XPropertySetInfo > xInfo( new PropertySetInfo_Impl( seq ) ); - MutexGuard aGuard( m_mutex ); + MutexGuard aGuard( m_aMutex ); if (! m_xPropertyInfo.is()) { m_xPropertyInfo = xInfo; @@ -1442,7 +1439,7 @@ Any ORegistryServiceManager::getPropertyValue(const OUString& PropertyName) check_undisposed(); if ( PropertyName == "Registry" ) { - MutexGuard aGuard( m_mutex ); + MutexGuard aGuard( m_aMutex ); if( m_xRegistry.is() ) return makeAny( m_xRegistry ); else diff --git a/svx/source/inc/gridcell.hxx b/svx/source/inc/gridcell.hxx index 8a2c40dcf340..ed9e5eb2722e 100644 --- a/svx/source/inc/gridcell.hxx +++ b/svx/source/inc/gridcell.hxx @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -57,13 +58,6 @@ namespace dbtools { class FormattedColumnValue; } -class FmMutexHelper -{ -protected: - ::osl::Mutex m_aMutex; -}; - - // DbGridColumn, column description class DbGridColumn @@ -191,7 +185,7 @@ private: // Is usually only required for complex controls such as combo boxes. class DbCellControl - :public FmMutexHelper // _before_ the listener, so the listener is to be destroyed first! + :public cppu::BaseMutex // _before_ the listener, so the listener is to be destroyed first! ,public ::comphelper::OPropertyChangeListener { private: diff --git a/svx/source/unodraw/unoshcol.cxx b/svx/source/unodraw/unoshcol.cxx index 80ad53cc1f88..d4cbce783af7 100644 --- a/svx/source/unodraw/unoshcol.cxx +++ b/svx/source/unodraw/unoshcol.cxx @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -36,15 +37,9 @@ using namespace ::com::sun::star::uno; namespace { -class SvxShapeCollectionMutex -{ -public: - ::osl::Mutex maMutex; -}; - class SvxShapeCollection : - public cppu::WeakAggImplHelper3, - public SvxShapeCollectionMutex + public cppu::BaseMutex, + public cppu::WeakAggImplHelper3 { private: comphelper::OInterfaceContainerHelper3 maShapeContainer; @@ -81,7 +76,7 @@ public: }; SvxShapeCollection::SvxShapeCollection() noexcept -: maShapeContainer( maMutex ), mrBHelper( maMutex ) +: maShapeContainer( m_aMutex ), mrBHelper( m_aMutex ) { } diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx index 351166d713e3..fde41f8a30d2 100644 --- a/toolkit/source/awt/vclxtoolkit.cxx +++ b/toolkit/source/awt/vclxtoolkit.cxx @@ -48,6 +48,7 @@ #include #include +#include #include #include #include @@ -427,13 +428,7 @@ public: sal_Int32 m_nPauseMilliseconds; }; -class VCLXToolkitMutexHelper -{ -protected: - ::osl::Mutex maMutex; -}; - -class VCLXToolkit : public VCLXToolkitMutexHelper, +class VCLXToolkit : public cppu::BaseMutex, public cppu::WeakComponentImplHelper< css::awt::XToolkitExperimental, css::awt::XToolkitRobot, @@ -467,7 +462,7 @@ class VCLXToolkit : public VCLXToolkitMutexHelper, void callFocusListeners(::VclSimpleEvent const * pEvent, bool bGained); protected: - ::osl::Mutex& GetMutex() { return maMutex; } + ::osl::Mutex& GetMutex() { return m_aMutex; } virtual void SAL_CALL disposing() override;