summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2021-12-18 20:17:47 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-12-20 14:58:02 +0100
commit516fa8464f84378f5f6441555689f468ef2e8eb9 (patch)
tree8c4dd8ae356589a293afa6c19bee735c8008d346 /framework
parent20cd1d36916a55e0f89f39e876a61d52576ee0b1 (diff)
osl::Mutex->std::mutex in ImageManagerImpl
Change-Id: I2feae13f2d8fe90d1f3b072156f3e384fd71db82 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127108 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'framework')
-rw-r--r--framework/source/uiconfiguration/imagemanagerimpl.cxx36
-rw-r--r--framework/source/uiconfiguration/imagemanagerimpl.hxx8
2 files changed, 26 insertions, 18 deletions
diff --git a/framework/source/uiconfiguration/imagemanagerimpl.cxx b/framework/source/uiconfiguration/imagemanagerimpl.cxx
index 47d4e3825cc3..ae8a5b310fcc 100644
--- a/framework/source/uiconfiguration/imagemanagerimpl.cxx
+++ b/framework/source/uiconfiguration/imagemanagerimpl.cxx
@@ -478,7 +478,6 @@ ImageManagerImpl::ImageManagerImpl( const uno::Reference< uno::XComponentContext
m_xContext( rxContext )
, m_pOwner(pOwner)
, m_aResourceString( "private:resource/images/moduleimages" )
- , m_aListenerContainer( m_mutex )
, m_bUseGlobal(_bUseGlobal)
, m_bReadOnly( true )
, m_bInitialized( false )
@@ -501,7 +500,14 @@ void ImageManagerImpl::dispose()
{
uno::Reference< uno::XInterface > xOwner(m_pOwner);
css::lang::EventObject aEvent( xOwner );
- m_aListenerContainer.disposeAndClear( aEvent );
+ {
+ std::unique_lock aGuard(m_mutex);
+ m_aEventListeners.disposeAndClear( aGuard, aEvent );
+ }
+ {
+ std::unique_lock aGuard(m_mutex);
+ m_aConfigListeners.disposeAndClear( aGuard, aEvent );
+ }
{
SolarMutexGuard g;
@@ -530,13 +536,15 @@ void ImageManagerImpl::addEventListener( const uno::Reference< XEventListener >&
throw DisposedException();
}
- m_aListenerContainer.addInterface( cppu::UnoType<XEventListener>::get(), xListener );
+ std::unique_lock aGuard(m_mutex);
+ m_aEventListeners.addInterface( xListener );
}
void ImageManagerImpl::removeEventListener( const uno::Reference< XEventListener >& xListener )
{
/* SAFE AREA ----------------------------------------------------------------------------------------------- */
- m_aListenerContainer.removeInterface( cppu::UnoType<XEventListener>::get(), xListener );
+ std::unique_lock aGuard(m_mutex);
+ m_aEventListeners.removeInterface( xListener );
}
// XInitialization
@@ -1145,23 +1153,21 @@ void ImageManagerImpl::addConfigurationListener( const uno::Reference< css::ui::
throw DisposedException();
}
- m_aListenerContainer.addInterface( cppu::UnoType<XUIConfigurationListener>::get(), xListener );
+ std::unique_lock aGuard(m_mutex);
+ m_aConfigListeners.addInterface( xListener );
}
void ImageManagerImpl::removeConfigurationListener( const uno::Reference< css::ui::XUIConfigurationListener >& xListener )
{
/* SAFE AREA ----------------------------------------------------------------------------------------------- */
- m_aListenerContainer.removeInterface( cppu::UnoType<XUIConfigurationListener>::get(), xListener );
+ std::unique_lock aGuard(m_mutex);
+ m_aConfigListeners.removeInterface( xListener );
}
void ImageManagerImpl::implts_notifyContainerListener( const ConfigurationEvent& aEvent, NotifyOp eOp )
{
- comphelper::OInterfaceContainerHelper2* pContainer = m_aListenerContainer.getContainer(
- cppu::UnoType<css::ui::XUIConfigurationListener>::get());
- if ( pContainer == nullptr )
- return;
-
- comphelper::OInterfaceIteratorHelper2 pIterator( *pContainer );
+ std::unique_lock aGuard(m_mutex);
+ comphelper::OInterfaceIteratorHelper4 pIterator( m_aConfigListeners );
while ( pIterator.hasMoreElements() )
{
try
@@ -1169,13 +1175,13 @@ void ImageManagerImpl::implts_notifyContainerListener( const ConfigurationEvent&
switch ( eOp )
{
case NotifyOp_Replace:
- static_cast< css::ui::XUIConfigurationListener*>(pIterator.next())->elementReplaced( aEvent );
+ pIterator.next()->elementReplaced( aEvent );
break;
case NotifyOp_Insert:
- static_cast< css::ui::XUIConfigurationListener*>(pIterator.next())->elementInserted( aEvent );
+ pIterator.next()->elementInserted( aEvent );
break;
case NotifyOp_Remove:
- static_cast< css::ui::XUIConfigurationListener*>(pIterator.next())->elementRemoved( aEvent );
+ pIterator.next()->elementRemoved( aEvent );
break;
}
}
diff --git a/framework/source/uiconfiguration/imagemanagerimpl.hxx b/framework/source/uiconfiguration/imagemanagerimpl.hxx
index 9bc6f4eb7077..88f4a8349398 100644
--- a/framework/source/uiconfiguration/imagemanagerimpl.hxx
+++ b/framework/source/uiconfiguration/imagemanagerimpl.hxx
@@ -27,12 +27,13 @@
#include <com/sun/star/embed/XTransactedObject.hpp>
#include <cppuhelper/weak.hxx>
-#include <comphelper/multicontainer2.hxx>
+#include <comphelper/interfacecontainer4.hxx>
#include <rtl/ustring.hxx>
#include <rtl/ref.hxx>
#include <salhelper/simplereferenceobject.hxx>
+#include <mutex>
#include <unordered_map>
#include <vector>
@@ -170,8 +171,9 @@ namespace framework
std::unique_ptr<CmdImageList> m_pDefaultImageList;
OUString m_aModuleIdentifier;
OUString m_aResourceString;
- osl::Mutex m_mutex;
- comphelper::OMultiTypeInterfaceContainerHelper2 m_aListenerContainer; /// container for ALL Listener
+ std::mutex m_mutex;
+ comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aEventListeners;
+ comphelper::OInterfaceContainerHelper4<css::ui::XUIConfigurationListener> m_aConfigListeners;
o3tl::enumarray<vcl::ImageType,std::unique_ptr<ImageList>> m_pUserImageList;
o3tl::enumarray<vcl::ImageType,bool> m_bUserImageListModified;
bool m_bUseGlobal;