summaryrefslogtreecommitdiff
path: root/configmgr
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2023-02-20 20:08:30 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-02-21 09:12:17 +0000
commita61951a3a21c6457334f78f657806c1167dbf339 (patch)
treea6dcb7640faeecf4666b6c8f559199ae9234172c /configmgr
parentbf9f9f1fbda73ea65d455d520954e2d38bbccb1d (diff)
BaseMutex->std::mutex in configmgr::configuration_provider::Service
Change-Id: Ie8f7cb4cd91ac0089365a691f07962a26d51a72a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147377 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'configmgr')
-rw-r--r--configmgr/source/configurationprovider.cxx59
1 files changed, 28 insertions, 31 deletions
diff --git a/configmgr/source/configurationprovider.cxx b/configmgr/source/configurationprovider.cxx
index b8bdcb4262f2..ddff084a1b03 100644
--- a/configmgr/source/configurationprovider.cxx
+++ b/configmgr/source/configurationprovider.cxx
@@ -39,8 +39,7 @@
#include <com/sun/star/util/XRefreshListener.hpp>
#include <com/sun/star/util/XRefreshable.hpp>
#include <cppu/unotype.hxx>
-#include <cppuhelper/basemutex.hxx>
-#include <cppuhelper/compbase.hxx>
+#include <comphelper/compbase.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <cppuhelper/weak.hxx>
#include <osl/mutex.hxx>
@@ -74,19 +73,18 @@ void badNodePath() {
}
typedef
- cppu::WeakComponentImplHelper<
+ comphelper::WeakComponentImplHelper<
css::lang::XServiceInfo, css::lang::XMultiServiceFactory,
css::util::XRefreshable, css::util::XFlushable,
css::lang::XLocalizable >
ServiceBase;
-class Service:
- private cppu::BaseMutex, public ServiceBase
+class Service : public ServiceBase
{
public:
explicit Service(
const css::uno::Reference< css::uno::XComponentContext >& context):
- ServiceBase(m_aMutex), context_(context), default_(true),
+ context_(context), default_(true),
lock_( lock() )
{
assert(context.is());
@@ -95,7 +93,7 @@ public:
Service(
const css::uno::Reference< css::uno::XComponentContext >& context,
OUString locale):
- ServiceBase(m_aMutex), context_(context), locale_(std::move(locale)),
+ context_(context), locale_(std::move(locale)),
default_(false),
lock_( lock() )
{
@@ -108,7 +106,7 @@ private:
virtual ~Service() override {}
- virtual void SAL_CALL disposing() override { flushModifications(); }
+ virtual void disposing(std::unique_lock<std::mutex>& rGuard) override { flushModifications(rGuard); }
virtual OUString SAL_CALL getImplementationName() override
{
@@ -159,12 +157,14 @@ private:
virtual css::lang::Locale SAL_CALL getLocale() override;
- void flushModifications() const;
+ void flushModifications(std::unique_lock<std::mutex>& rGuard) const;
css::uno::Reference< css::uno::XComponentContext > context_;
OUString locale_;
bool default_;
std::shared_ptr<osl::Mutex> lock_;
+ comphelper::OInterfaceContainerHelper4<css::util::XRefreshListener> maRefreshListeners;
+ comphelper::OInterfaceContainerHelper4<css::util::XFlushListener> maFlushListeners;
};
css::uno::Reference< css::uno::XInterface > Service::createInstance(
@@ -271,49 +271,48 @@ css::uno::Sequence< OUString > Service::getAvailableServiceNames()
void Service::refresh() {
//TODO
- cppu::OInterfaceContainerHelper * cont = rBHelper.getContainer(
- cppu::UnoType< css::util::XRefreshListener >::get());
- if (cont != nullptr) {
+ std::unique_lock g(m_aMutex);
+ if (maRefreshListeners.getLength(g)) {
css::lang::EventObject ev(static_cast< cppu::OWeakObject * >(this));
- cont->notifyEach(&css::util::XRefreshListener::refreshed, ev);
+ maRefreshListeners.notifyEach(g, &css::util::XRefreshListener::refreshed, ev);
}
}
void Service::addRefreshListener(
css::uno::Reference< css::util::XRefreshListener > const & l)
{
- rBHelper.addListener(
- cppu::UnoType< css::util::XRefreshListener >::get(), l);
+ std::unique_lock g(m_aMutex);
+ maRefreshListeners.addInterface(g, l);
}
void Service::removeRefreshListener(
css::uno::Reference< css::util::XRefreshListener > const & l)
{
- rBHelper.removeListener(
- cppu::UnoType< css::util::XRefreshListener >::get(), l);
+ std::unique_lock g(m_aMutex);
+ maRefreshListeners.removeInterface(g, l);
}
void Service::flush() {
- flushModifications();
- cppu::OInterfaceContainerHelper * cont = rBHelper.getContainer(
- cppu::UnoType< css::util::XFlushListener >::get());
- if (cont != nullptr) {
+ std::unique_lock g(m_aMutex);
+ flushModifications(g);
+ if (maFlushListeners.getLength(g)) {
css::lang::EventObject ev(static_cast< cppu::OWeakObject * >(this));
- cont->notifyEach(&css::util::XFlushListener::flushed, ev);
+ maFlushListeners.notifyEach(g, &css::util::XFlushListener::flushed, ev);
}
}
void Service::addFlushListener(
css::uno::Reference< css::util::XFlushListener > const & l)
{
- rBHelper.addListener(cppu::UnoType< css::util::XFlushListener >::get(), l);
+ std::unique_lock g(m_aMutex);
+ maFlushListeners.addInterface(g, l);
}
void Service::removeFlushListener(
css::uno::Reference< css::util::XFlushListener > const & l)
{
- rBHelper.removeListener(
- cppu::UnoType< css::util::XFlushListener >::get(), l);
+ std::unique_lock g(m_aMutex);
+ maFlushListeners.removeInterface(g, l);
}
void Service::setLocale(css::lang::Locale const & eLocale)
@@ -331,13 +330,11 @@ css::lang::Locale Service::getLocale() {
return loc;
}
-void Service::flushModifications() const {
- Components * components;
- {
- osl::MutexGuard guard(*lock_);
- components = &Components::getSingleton(context_);
- }
+void Service::flushModifications(std::unique_lock<std::mutex>& rGuard) const {
+ Components * components = &Components::getSingleton(context_);
+ rGuard.unlock();
components->flushModifications();
+ rGuard.lock();
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*