summaryrefslogtreecommitdiff
path: root/toolkit
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2021-08-23 21:44:56 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-08-25 09:10:50 +0200
commitb27ede1a629ac2b5f9e98def37326d546923edec (patch)
treec3bd097378ce5107895551c6f179321ede9989be /toolkit
parent400a44261c3891c1fb99b5339ada69cbc4777dd0 (diff)
osl::Mutex->std::mutex in ResourceListener
Change-Id: Ide7073273be3405a1d78687a2d6dd12369dd226d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120955 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'toolkit')
-rw-r--r--toolkit/inc/controls/controlmodelcontainerbase.hxx5
-rw-r--r--toolkit/source/controls/controlmodelcontainerbase.cxx34
2 files changed, 20 insertions, 19 deletions
diff --git a/toolkit/inc/controls/controlmodelcontainerbase.hxx b/toolkit/inc/controls/controlmodelcontainerbase.hxx
index df5b4aac89a7..e84bb4267e42 100644
--- a/toolkit/inc/controls/controlmodelcontainerbase.hxx
+++ b/toolkit/inc/controls/controlmodelcontainerbase.hxx
@@ -37,6 +37,7 @@
#include <cppuhelper/basemutex.hxx>
#include <com/sun/star/awt/tab/XTabPageModel.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
+#include <mutex>
#include <vector>
namespace com::sun::star::resource { class XStringResourceResolver; }
@@ -181,8 +182,7 @@ protected:
};
class ResourceListener final : public css::util::XModifyListener,
- public ::cppu::OWeakObject,
- public ::cppu::BaseMutex
+ public ::cppu::OWeakObject
{
public:
ResourceListener( const css::uno::Reference< css::util::XModifyListener >& xListener );
@@ -203,6 +203,7 @@ class ResourceListener final : public css::util::XModifyListener,
virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
private:
+ std::mutex m_aMutex;
css::uno::Reference< css::resource::XStringResourceResolver > m_xResource;
css::uno::Reference< css::util::XModifyListener > m_xListener;
bool m_bListening;
diff --git a/toolkit/source/controls/controlmodelcontainerbase.cxx b/toolkit/source/controls/controlmodelcontainerbase.cxx
index 62453331474b..2731423fdf5e 100644
--- a/toolkit/source/controls/controlmodelcontainerbase.cxx
+++ b/toolkit/source/controls/controlmodelcontainerbase.cxx
@@ -1084,19 +1084,19 @@ void ResourceListener::startListening(
{
{
// --- SAFE ---
- ::osl::ResettableGuard < ::osl::Mutex > aGuard( m_aMutex );
+ std::unique_lock aGuard( m_aMutex );
bool bListening( m_bListening );
bool bResourceSet( m_xResource.is() );
- aGuard.clear();
+ aGuard.unlock();
// --- SAFE ---
if ( bListening && bResourceSet )
stopListening();
// --- SAFE ---
- aGuard.reset();
+ aGuard.lock();
m_xResource = rResource;
- aGuard.clear();
+ aGuard.unlock();
// --- SAFE ---
}
@@ -1108,7 +1108,7 @@ void ResourceListener::startListening(
rResource->addModifyListener( this );
// --- SAFE ---
- ::osl::ResettableGuard < ::osl::Mutex > aGuard( m_aMutex );
+ std::scoped_lock aGuard( m_aMutex );
m_bListening = true;
// --- SAFE ---
}
@@ -1126,10 +1126,10 @@ void ResourceListener::stopListening()
Reference< util::XModifyBroadcaster > xModifyBroadcaster;
// --- SAFE ---
- ::osl::ResettableGuard < ::osl::Mutex > aGuard( m_aMutex );
+ std::unique_lock aGuard( m_aMutex );
if ( m_bListening && m_xResource.is() )
xModifyBroadcaster = m_xResource;
- aGuard.clear();
+ aGuard.unlock();
// --- SAFE ---
if ( !xModifyBroadcaster.is() )
@@ -1138,10 +1138,10 @@ void ResourceListener::stopListening()
try
{
// --- SAFE ---
- aGuard.reset();
+ aGuard.lock();
m_bListening = false;
m_xResource.clear();
- aGuard.clear();
+ aGuard.unlock();
// --- SAFE ---
xModifyBroadcaster->removeModifyListener( this );
@@ -1162,9 +1162,9 @@ void SAL_CALL ResourceListener::modified(
Reference< util::XModifyListener > xListener;
// --- SAFE ---
- ::osl::ResettableGuard < ::osl::Mutex > aGuard( m_aMutex );
+ std::unique_lock aGuard( m_aMutex );
xListener = m_xListener;
- aGuard.clear();
+ aGuard.unlock();
// --- SAFE ---
if ( !xListener.is() )
@@ -1191,21 +1191,21 @@ void SAL_CALL ResourceListener::disposing(
Reference< resource::XStringResourceResolver > xResource;
// --- SAFE ---
- ::osl::ResettableGuard < ::osl::Mutex > aGuard( m_aMutex );
+ std::unique_lock aGuard( m_aMutex );
Reference< XInterface > xIfacRes( m_xResource, UNO_QUERY );
Reference< XInterface > xIfacList( m_xListener, UNO_QUERY );
- aGuard.clear();
+ aGuard.unlock();
// --- SAFE ---
if ( Source.Source == xIfacRes )
{
// --- SAFE ---
- aGuard.reset();
+ aGuard.lock();
m_bListening = false;
xResource = m_xResource;
xListener = m_xListener;
m_xResource.clear();
- aGuard.clear();
+ aGuard.unlock();
// --- SAFE ---
if ( xListener.is() )
@@ -1226,13 +1226,13 @@ void SAL_CALL ResourceListener::disposing(
else if ( Source.Source == xIfacList )
{
// --- SAFE ---
- aGuard.reset();
+ aGuard.lock();
m_bListening = false;
xListener = m_xListener;
xResource = m_xResource;
m_xResource.clear();
m_xListener.clear();
- aGuard.clear();
+ aGuard.unlock();
// --- SAFE ---
// Remove ourself as listener from resource resolver