diff --git a/comphelper/source/misc/configuration.cxx b/comphelper/source/misc/configuration.cxx index e5bf8b84d2d2..ea01ceae43f0 100644 --- a/comphelper/source/misc/configuration.cxx +++ b/comphelper/source/misc/configuration.cxx @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -248,6 +249,12 @@ void SAL_CALL comphelper::ConfigurationListener::propertyChange( css::beans::PropertyChangeEvent const &rEvt ) throw (css::uno::RuntimeException, std::exception) { + // Code is commonly used inside the SolarMutexGuard + // so to avoid concurrent writes to the property, + // and allow fast, lock-less access, guard here. + rtl::Reference< comphelper::SolarMutex > xMutexGuard( + comphelper::SolarMutex::get() ); + assert( rEvt.Source == mxConfig ); for ( auto it = maListeners.begin(); it != maListeners.end(); ++it ) { diff --git a/include/comphelper/configurationlistener.hxx b/include/comphelper/configurationlistener.hxx index 88edd77ff1b5..0b9a872e777e 100644 --- a/include/comphelper/configurationlistener.hxx +++ b/include/comphelper/configurationlistener.hxx @@ -37,6 +37,7 @@ public: void dispose() { mxListener.clear(); } }; +/// Access to this class must be protected by the SolarMutex template< typename uno_type > class ConfigurationListenerProperty : public ConfigurationListenerPropertyBase { uno_type maValue;