summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-01-14 10:56:50 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-01-14 21:04:10 +0100
commita2eaf99e46f370ffb3b73828c2bdc53dc193b9a4 (patch)
tree6d08d7b5077478a92acde6dd6e7278e98a409ce1 /svx
parent49a5e69f567302633299bf6626a9d9b9544ee94b (diff)
make comphelper::OInterfaceContainerHelper4 more threadsafe
(*) make all the methods that require an external mutex take a std::unique_lock as a parameter, so that call sites cannot forget (*) make the forEach method drop the lock when firing listener methods, to reduce the odds of deadlock Change-Id: I0a80e3b3d1c1c03b7de4a658d31fcc2847690903 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128415 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/table/tabledesign.cxx12
-rw-r--r--svx/source/unodialogs/textconversiondlgs/chinese_translation_unodialog.cxx4
2 files changed, 8 insertions, 8 deletions
diff --git a/svx/source/table/tabledesign.cxx b/svx/source/table/tabledesign.cxx
index d383898adae1..935cebefe4bd 100644
--- a/svx/source/table/tabledesign.cxx
+++ b/svx/source/table/tabledesign.cxx
@@ -228,9 +228,9 @@ sal_Bool SAL_CALL TableDesignStyle::isUserDefined()
sal_Bool SAL_CALL TableDesignStyle::isInUse()
{
std::unique_lock aGuard( m_aMutex );
- if (maModifyListeners.getLength())
+ if (maModifyListeners.getLength(aGuard))
{
- comphelper::OInterfaceIteratorHelper4 it(maModifyListeners);
+ comphelper::OInterfaceIteratorHelper4 it(aGuard, maModifyListeners);
while ( it.hasMoreElements() )
{
TableDesignUser* pUser = dynamic_cast< TableDesignUser* >( it.next().get() );
@@ -396,7 +396,7 @@ void SAL_CALL TableDesignStyle::addModifyListener( const Reference< XModifyListe
}
else
{
- maModifyListeners.addInterface( xListener );
+ maModifyListeners.addInterface( aGuard, xListener );
}
}
@@ -404,7 +404,7 @@ void SAL_CALL TableDesignStyle::addModifyListener( const Reference< XModifyListe
void SAL_CALL TableDesignStyle::removeModifyListener( const Reference< XModifyListener >& xListener )
{
std::unique_lock aGuard( m_aMutex );
- maModifyListeners.removeInterface( xListener );
+ maModifyListeners.removeInterface( aGuard, xListener );
}
@@ -412,10 +412,10 @@ void TableDesignStyle::notifyModifyListener()
{
std::unique_lock aGuard( m_aMutex );
- if( maModifyListeners.getLength() )
+ if( maModifyListeners.getLength(aGuard) )
{
EventObject aEvt( static_cast< OWeakObject * >( this ) );
- maModifyListeners.forEach(
+ maModifyListeners.forEach(aGuard,
[&] (Reference<XModifyListener> const& xListener)
{ return xListener->modified(aEvt); });
}
diff --git a/svx/source/unodialogs/textconversiondlgs/chinese_translation_unodialog.cxx b/svx/source/unodialogs/textconversiondlgs/chinese_translation_unodialog.cxx
index 80cda9bb6555..466a4efca29e 100644
--- a/svx/source/unodialogs/textconversiondlgs/chinese_translation_unodialog.cxx
+++ b/svx/source/unodialogs/textconversiondlgs/chinese_translation_unodialog.cxx
@@ -134,7 +134,7 @@ void SAL_CALL ChineseTranslation_UnoDialog::addEventListener( const uno::Referen
if( m_bDisposed || m_bInDispose )
return;
std::unique_lock aGuard(m_aContainerMutex);
- m_aDisposeEventListeners.addInterface( xListener );
+ m_aDisposeEventListeners.addInterface( aGuard, xListener );
}
void SAL_CALL ChineseTranslation_UnoDialog::removeEventListener( const uno::Reference< lang::XEventListener > & xListener )
@@ -143,7 +143,7 @@ void SAL_CALL ChineseTranslation_UnoDialog::removeEventListener( const uno::Refe
if( m_bDisposed || m_bInDispose )
return;
std::unique_lock aGuard(m_aContainerMutex);
- m_aDisposeEventListeners.removeInterface( xListener );
+ m_aDisposeEventListeners.removeInterface( aGuard, xListener );
}