diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-02-22 15:03:49 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-02-24 10:07:39 +0000 |
commit | 2f72de90f8a27b06aae0bf9ede93ed640764498b (patch) | |
tree | a03c30686ebf1efa19508ba57fe810b62a6c8b99 /sot | |
parent | d6182cb6704c06f33d284874b9fe96c85cce5bf5 (diff) |
osl::Mutex->std::mutex in OLESimpleStorage
Change-Id: I3ff011fa4829bd7230ddaa8fc2d34ade47f09b0d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147466
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sot')
-rw-r--r-- | sot/source/unoolestorage/xolesimplestorage.cxx | 47 | ||||
-rw-r--r-- | sot/source/unoolestorage/xolesimplestorage.hxx | 8 |
2 files changed, 22 insertions, 33 deletions
diff --git a/sot/source/unoolestorage/xolesimplestorage.cxx b/sot/source/unoolestorage/xolesimplestorage.cxx index 49a785ed5ff9..d64937d9b4e0 100644 --- a/sot/source/unoolestorage/xolesimplestorage.cxx +++ b/sot/source/unoolestorage/xolesimplestorage.cxx @@ -46,7 +46,6 @@ OLESimpleStorage::OLESimpleStorage( css::uno::Reference<css::uno::XComponentContext> xContext, css::uno::Sequence<css::uno::Any> const &aArguments) : m_bDisposed( false ) -, m_pListenersContainer( nullptr ) , m_xContext(std::move( xContext )) , m_bNoTemporaryCopy( false ) { @@ -145,12 +144,6 @@ OLESimpleStorage::~OLESimpleStorage() dispose(); } catch( uno::Exception& ) {} - - if ( m_pListenersContainer ) - { - delete m_pListenersContainer; - m_pListenersContainer = nullptr; - } } void OLESimpleStorage::UpdateOriginal_Impl() @@ -263,7 +256,7 @@ void OLESimpleStorage::InsertNameAccessToStorage_Impl( BaseStorage* pStorage, co void SAL_CALL OLESimpleStorage::insertByName( const OUString& aName, const uno::Any& aElement ) { - ::osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); if ( m_bDisposed ) throw lang::DisposedException(); @@ -312,7 +305,7 @@ void SAL_CALL OLESimpleStorage::insertByName( const OUString& aName, const uno:: void SAL_CALL OLESimpleStorage::removeByName( const OUString& aName ) { - ::osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); if ( m_bDisposed ) throw lang::DisposedException(); @@ -338,7 +331,7 @@ void SAL_CALL OLESimpleStorage::removeByName( const OUString& aName ) void SAL_CALL OLESimpleStorage::replaceByName( const OUString& aName, const uno::Any& aElement ) { - ::osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); if ( m_bDisposed ) throw lang::DisposedException(); @@ -362,7 +355,7 @@ void SAL_CALL OLESimpleStorage::replaceByName( const OUString& aName, const uno: uno::Any SAL_CALL OLESimpleStorage::getByName( const OUString& aName ) { - ::osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); if ( m_bDisposed ) throw lang::DisposedException(); @@ -463,7 +456,7 @@ uno::Any SAL_CALL OLESimpleStorage::getByName( const OUString& aName ) uno::Sequence< OUString > SAL_CALL OLESimpleStorage::getElementNames() { - ::osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); if ( m_bDisposed ) throw lang::DisposedException(); @@ -491,7 +484,7 @@ uno::Sequence< OUString > SAL_CALL OLESimpleStorage::getElementNames() sal_Bool SAL_CALL OLESimpleStorage::hasByName( const OUString& aName ) { - ::osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); if ( m_bDisposed ) throw lang::DisposedException(); @@ -513,7 +506,7 @@ sal_Bool SAL_CALL OLESimpleStorage::hasByName( const OUString& aName ) uno::Type SAL_CALL OLESimpleStorage::getElementType() { - ::osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); if ( m_bDisposed ) throw lang::DisposedException(); @@ -524,7 +517,7 @@ uno::Type SAL_CALL OLESimpleStorage::getElementType() sal_Bool SAL_CALL OLESimpleStorage::hasElements() { - ::osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); if ( m_bDisposed ) throw lang::DisposedException(); @@ -550,15 +543,15 @@ sal_Bool SAL_CALL OLESimpleStorage::hasElements() void SAL_CALL OLESimpleStorage::dispose() { - ::osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); if ( m_bDisposed ) throw lang::DisposedException(); - if ( m_pListenersContainer ) + if ( m_aListenersContainer.getLength(aGuard) ) { lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >(this) ); - m_pListenersContainer->disposeAndClear( aSource ); + m_aListenersContainer.disposeAndClear( aGuard, aSource ); } m_pStorage.reset(); @@ -574,28 +567,24 @@ void SAL_CALL OLESimpleStorage::dispose() void SAL_CALL OLESimpleStorage::addEventListener( const uno::Reference< lang::XEventListener >& xListener ) { - ::osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); if ( m_bDisposed ) throw lang::DisposedException(); - if ( !m_pListenersContainer ) - m_pListenersContainer = new ::comphelper::OInterfaceContainerHelper3<css::lang::XEventListener>( m_aMutex ); - - m_pListenersContainer->addInterface( xListener ); + m_aListenersContainer.addInterface( aGuard, xListener ); } void SAL_CALL OLESimpleStorage::removeEventListener( const uno::Reference< lang::XEventListener >& xListener ) { - ::osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); if ( m_bDisposed ) throw lang::DisposedException(); - if ( m_pListenersContainer ) - m_pListenersContainer->removeInterface( xListener ); + m_aListenersContainer.removeInterface( aGuard, xListener ); } @@ -604,7 +593,7 @@ void SAL_CALL OLESimpleStorage::removeEventListener( void SAL_CALL OLESimpleStorage::commit() { - ::osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); if ( m_bDisposed ) throw lang::DisposedException(); @@ -627,7 +616,7 @@ void SAL_CALL OLESimpleStorage::commit() void SAL_CALL OLESimpleStorage::revert() { - ::osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); if ( m_bDisposed ) throw lang::DisposedException(); @@ -653,7 +642,7 @@ void SAL_CALL OLESimpleStorage::revert() uno::Sequence< sal_Int8 > SAL_CALL OLESimpleStorage::getClassID() { - ::osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); if ( m_bDisposed ) throw lang::DisposedException(); diff --git a/sot/source/unoolestorage/xolesimplestorage.hxx b/sot/source/unoolestorage/xolesimplestorage.hxx index eedfc81c29ac..da3e3bd5bcdb 100644 --- a/sot/source/unoolestorage/xolesimplestorage.hxx +++ b/sot/source/unoolestorage/xolesimplestorage.hxx @@ -24,12 +24,12 @@ #include <memory> -#include <comphelper/interfacecontainer3.hxx> +#include <comphelper/interfacecontainer4.hxx> #include <com/sun/star/embed/XOLESimpleStorage.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <cppuhelper/implbase.hxx> -#include <osl/mutex.hxx> +#include <mutex> namespace com::sun::star::container { class XNameAccess; } namespace com::sun::star::io { class XInputStream; } @@ -42,7 +42,7 @@ class SvStream; class OLESimpleStorage : public cppu::WeakImplHelper<css::embed::XOLESimpleStorage, css::lang::XServiceInfo> { - ::osl::Mutex m_aMutex; + std::mutex m_aMutex; bool m_bDisposed; @@ -51,7 +51,7 @@ class OLESimpleStorage : public cppu::WeakImplHelper<css::embed::XOLESimpleStora std::unique_ptr<SvStream> m_pStream; std::unique_ptr<BaseStorage> m_pStorage; - ::comphelper::OInterfaceContainerHelper3<css::lang::XEventListener>* m_pListenersContainer; // list of listeners + ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aListenersContainer; // list of listeners css::uno::Reference<css::uno::XComponentContext> m_xContext; bool m_bNoTemporaryCopy; |