basic/source/basmgr/vbahelper.cxx | 5 +- stoc/source/servicemanager/servicemanager.cxx | 63 ++++++++++++-------------- svx/source/inc/gridcell.hxx | 10 ---- svx/source/unodraw/unoshcol.cxx | 13 +---- toolkit/source/awt/vclxtoolkit.cxx | 11 +--- 5 files changed, 42 insertions(+), 60 deletions(-)
New commits: commit 4f043fb3e78429277ba94f05f57fae408d6bda12 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Fri Dec 17 18:54:00 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sat Dec 18 19:08:16 2021 +0100 osl::Mutex->std::mutex in CurrDirPool Change-Id: I889f643266c6f087c34f681e71f27d8ab493e04c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127073 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/basic/source/basmgr/vbahelper.cxx b/basic/source/basmgr/vbahelper.cxx index 7fa101a8259e..caccb9bfc16e 100644 --- a/basic/source/basmgr/vbahelper.cxx +++ b/basic/source/basmgr/vbahelper.cxx @@ -21,6 +21,7 @@ #include <basic/vbahelper.hxx> #include <map> +#include <mutex> #include <vector> #include <com/sun/star/container/XEnumeration.hpp> #include <com/sun/star/frame/Desktop.hpp> @@ -140,7 +141,7 @@ void lclIterateDocuments( ModifyDocumentFunc pModifyDocumentFunc, const uno::Ref struct CurrDirPool { - ::osl::Mutex maMutex; + std::mutex maMutex; std::map< OUString, OUString > maCurrDirs; }; @@ -167,7 +168,7 @@ void registerCurrentDirectory( const uno::Reference< frame::XModel >& rxModel, c static CurrDirPool StaticCurrDirPool; CurrDirPool& rPool = StaticCurrDirPool; - ::osl::MutexGuard aGuard( rPool.maMutex ); + std::unique_lock aGuard( rPool.maMutex ); try { uno::Reference< frame::XModuleManager2 > xModuleManager( lclCreateModuleManager() ); commit 6b16793cd13e540c1dfc1686df948c0dbcbe8068 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Sat Dec 18 09:20:08 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sat Dec 18 19:08:05 2021 +0100 use more cppu::BaseMutex Change-Id: I1ee9aff2774a673666c332c116aa5b0ba0d8b585 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127077 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> 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 <sal/log.hxx> #include <tools/diagnose_ex.h> +#include <cppuhelper/basemutex.hxx> #include <cppuhelper/factory.hxx> #include <cppuhelper/weakref.hxx> #include <cppuhelper/implbase.hxx> @@ -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<OWeakObject *>(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<XPropertySetInfo > OServiceManager::getPropertySetInfo() "DefaultContext", -1, cppu::UnoType<decltype(m_xContext)>::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<OWeakObject *>(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<XEventListener > 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<XEnumeration > OServiceManager::createContentEnumeration( Reference<XEnumeration > 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<XInterface > 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<OUString>(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<XInterface > 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<OUString>(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<XRegistryKey > 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<XEnumeration > 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<OUString> aImpls = getFromServiceName( aServiceName ); // load and insert all factories specified by the registry @@ -1428,7 +1425,7 @@ Reference<XPropertySetInfo > 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 <comphelper/interfacecontainer3.hxx> #include <comphelper/uno3.hxx> #include <connectivity/formattedcolumnvalue.hxx> +#include <cppuhelper/basemutex.hxx> #include <cppuhelper/component.hxx> #include <cppuhelper/implbase1.hxx> #include <cppuhelper/implbase2.hxx> @@ -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 <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/uno/XComponentContext.hpp> +#include <cppuhelper/basemutex.hxx> #include <cppuhelper/implbase3.hxx> #include <cppuhelper/interfacecontainer.hxx> #include <comphelper/interfacecontainer3.hxx> @@ -36,15 +37,9 @@ using namespace ::com::sun::star::uno; namespace { -class SvxShapeCollectionMutex -{ -public: - ::osl::Mutex maMutex; -}; - class SvxShapeCollection : - public cppu::WeakAggImplHelper3<drawing::XShapes, lang::XServiceInfo, lang::XComponent>, - public SvxShapeCollectionMutex + public cppu::BaseMutex, + public cppu::WeakAggImplHelper3<drawing::XShapes, lang::XServiceInfo, lang::XComponent> { private: comphelper::OInterfaceContainerHelper3<drawing::XShape> 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 <com/sun/star/awt/XToolkitExperimental.hpp> #include <com/sun/star/awt/XToolkitRobot.hpp> +#include <cppuhelper/basemutex.hxx> #include <cppuhelper/bootstrap.hxx> #include <cppuhelper/compbase.hxx> #include <cppuhelper/supportsservice.hxx> @@ -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;