tdf#149966 Crash on Windows and freeze on Linux when customizing Menu
use the notifyEach helper, which unlocks the mutex while we are
calling listeners, which means we can tolerate a re-entrant call to
removeConfigurationListener.
regression from
commit dab35c152af3345786b8335e83cd067b67d08b81
Author: Noel Grandin <noelgrandin@gmail.com>
Date: Sat Dec 18 20:24:15 2021 +0200
osl::Mutex->std::mutex in ModuleUIConfigurationManager
Change-Id: I7a2fbffb1c734b8bd0e952614592ce12c1611328
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137705
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
diff --git a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
index 9305835..ded9d77 100644
--- a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
+++ b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
@@ -1625,29 +1625,21 @@ sal_Bool SAL_CALL ModuleUIConfigurationManager::isReadOnly()
void ModuleUIConfigurationManager::implts_notifyContainerListener( const ui::ConfigurationEvent& aEvent, NotifyOp eOp )
{
std::unique_lock aGuard(m_mutex);
comphelper::OInterfaceIteratorHelper4 pIterator( aGuard, m_aConfigListeners );
while ( pIterator.hasMoreElements() )
using ListenerMethodType = void (SAL_CALL css::ui::XUIConfigurationListener::*)(const ui::ConfigurationEvent&);
ListenerMethodType aListenerMethod {};
switch ( eOp )
{
try
{
switch ( eOp )
{
case NotifyOp_Replace:
pIterator.next()->elementReplaced( aEvent );
break;
case NotifyOp_Insert:
pIterator.next()->elementInserted( aEvent );
break;
case NotifyOp_Remove:
pIterator.next()->elementRemoved( aEvent );
break;
}
}
catch( const css::uno::RuntimeException& )
{
pIterator.remove(aGuard);
}
case NotifyOp_Replace:
aListenerMethod = &css::ui::XUIConfigurationListener::elementReplaced;
break;
case NotifyOp_Insert:
aListenerMethod = &css::ui::XUIConfigurationListener::elementInserted;
break;
case NotifyOp_Remove:
aListenerMethod = &css::ui::XUIConfigurationListener::elementRemoved;
break;
}
m_aConfigListeners.notifyEach(aGuard, aListenerMethod, aEvent);
}
}