summaryrefslogtreecommitdiff
path: root/filter/source/config
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2023-02-22 11:23:53 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-02-22 13:44:11 +0000
commitf80e93a4241091ef1686e3850cd11c2b25d99b71 (patch)
tree84c288f25d7ab5d9aa5a8c5c6bd2876604c3050f /filter/source/config
parent28e7502be32f76ff20a38b644e29f1d6c40bbe24 (diff)
BaseMutex->std::mutex in ConfigFlush
Change-Id: Ia8c5d5cc6ea52ed385ae4ea3e860f2cc88d06377 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147456 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'filter/source/config')
-rw-r--r--filter/source/config/cache/configflush.cxx38
-rw-r--r--filter/source/config/cache/configflush.hxx11
2 files changed, 13 insertions, 36 deletions
diff --git a/filter/source/config/cache/configflush.cxx b/filter/source/config/cache/configflush.cxx
index 34ac28782b79..ed4da6d71185 100644
--- a/filter/source/config/cache/configflush.cxx
+++ b/filter/source/config/cache/configflush.cxx
@@ -26,7 +26,6 @@
namespace filter::config{
ConfigFlush::ConfigFlush()
- : m_lListener(m_aMutex)
{
}
@@ -57,46 +56,25 @@ void SAL_CALL ConfigFlush::refresh()
// and is threadsafe by itself.
// Further it's not a good idea to hold the own lock
// if an outside object is called :-)
- css::lang::EventObject aSource (static_cast< css::util::XRefreshable* >(this));
- comphelper::OInterfaceContainerHelper2* pContainer = m_lListener.getContainer(cppu::UnoType<css::util::XRefreshListener>::get());
- if (!pContainer)
+ std::unique_lock g(m_aMutex);
+ if (!m_aRefreshListeners.getLength(g))
return;
-
- comphelper::OInterfaceIteratorHelper2 pIterator(*pContainer);
- while (pIterator.hasMoreElements())
- {
- try
- {
- // ... this pointer can be interesting to find out, where will be called as listener
- // Don't optimize it to a direct iterator cast :-)
- css::util::XRefreshListener* pListener = static_cast<css::util::XRefreshListener*>(pIterator.next());
- pListener->refreshed(aSource);
- }
- catch(const css::uno::Exception&)
- {
- // ignore any "damaged" flush listener!
- // May its remote reference is broken ...
- pIterator.remove();
- }
- }
+ css::lang::EventObject aSource(static_cast< css::util::XRefreshable* >(this));
+ m_aRefreshListeners.notifyEach(g, &css::util::XRefreshListener::refreshed, aSource);
}
void SAL_CALL ConfigFlush::addRefreshListener(const css::uno::Reference< css::util::XRefreshListener >& xListener)
{
- // no locks necessary
- // used helper lives if we live and is threadsafe by itself ...
- m_lListener.addInterface(cppu::UnoType<css::util::XRefreshListener>::get(),
- xListener);
+ std::unique_lock g(m_aMutex);
+ m_aRefreshListeners.addInterface(g, xListener);
}
void SAL_CALL ConfigFlush::removeRefreshListener(const css::uno::Reference< css::util::XRefreshListener >& xListener)
{
- // no locks necessary
- // used helper lives if we live and is threadsafe by itself ...
- m_lListener.removeInterface(cppu::UnoType<css::util::XRefreshListener>::get(),
- xListener);
+ std::unique_lock g(m_aMutex);
+ m_aRefreshListeners.removeInterface(g, xListener);
}
diff --git a/filter/source/config/cache/configflush.hxx b/filter/source/config/cache/configflush.hxx
index d033516733ac..ba20c9e9d505 100644
--- a/filter/source/config/cache/configflush.hxx
+++ b/filter/source/config/cache/configflush.hxx
@@ -20,9 +20,8 @@
#include <com/sun/star/util/XRefreshable.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <comphelper/multicontainer2.hxx>
+#include <comphelper/interfacecontainer4.hxx>
#include <cppuhelper/implbase.hxx>
-#include <cppuhelper/basemutex.hxx>
namespace filter::config {
@@ -34,14 +33,14 @@ namespace filter::config {
@descr Such refresh listener will be called in case the
type/filter configuration will be changed at runtime.
*/
-class ConfigFlush final : public cppu::BaseMutex
- , public ::cppu::WeakImplHelper<
+class ConfigFlush final : public ::cppu::WeakImplHelper<
css::util::XRefreshable,
css::lang::XServiceInfo
>
{
- /** @short holds all listener, which are registered at this instance. */
- comphelper::OMultiTypeInterfaceContainerHelper2 m_lListener;
+ std::mutex m_aMutex;
+ /** @short holds all listener, which are registered at this instance. */
+ comphelper::OInterfaceContainerHelper4<css::util::XRefreshListener> m_aRefreshListeners;
// native interface