diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-03-27 16:08:15 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-03-29 16:24:29 +0100 |
commit | b6fdbbc1622a929e2699a67496a38431652eebdf (patch) | |
tree | 1b70c89a5472c7820e16eab0be6981a351e0b5cf | |
parent | cid#67704 Integer-overflow (diff) | |
download | core-b6fdbbc1622a929e2699a67496a38431652eebdf.tar.gz core-b6fdbbc1622a929e2699a67496a38431652eebdf.zip |
use std::mutex in StatusbarController
remove some locking in reportdesign::OStatusbarController -
those places are already locking using the solar mutex
Change-Id: I76d8e3a7ad60e4a2be1f0aac42967553356e9202
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165548
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | include/svtools/statusbarcontroller.hxx | 7 | ||||
-rw-r--r-- | reportdesign/source/ui/misc/statusbarcontroller.cxx | 2 | ||||
-rw-r--r-- | svtools/source/uno/statusbarcontroller.cxx | 17 |
3 files changed, 13 insertions, 13 deletions
diff --git a/include/svtools/statusbarcontroller.hxx b/include/svtools/statusbarcontroller.hxx index d5b9f9d2e926..d18cfde1b31c 100644 --- a/include/svtools/statusbarcontroller.hxx +++ b/include/svtools/statusbarcontroller.hxx @@ -22,8 +22,7 @@ #include <svtools/svtdllapi.h> #include <com/sun/star/frame/XStatusbarController.hpp> #include <cppuhelper/weak.hxx> -#include <comphelper/multicontainer2.hxx> -#include <cppuhelper/basemutex.hxx> +#include <comphelper/interfacecontainer4.hxx> #include <tools/gen.hxx> #include <unordered_map> #include <utility> @@ -41,7 +40,6 @@ namespace svt class SVT_DLLPUBLIC StatusbarController : public css::frame::XStatusbarController, - public ::cppu::BaseMutex, public ::cppu::OWeakObject { public: @@ -123,9 +121,10 @@ class SVT_DLLPUBLIC StatusbarController : css::uno::Reference< css::uno::XComponentContext > m_xContext; OUString m_aCommandURL; URLToDispatchMap m_aListenerMap; - comphelper::OMultiTypeInterfaceContainerHelper2 m_aListenerContainer; /// container for ALL Listener + comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aEventListeners; mutable css::uno::Reference< css::util::XURLTransformer > m_xURLTransformer; css::uno::Reference< css::ui::XStatusbarItem > m_xStatusbarItem; + std::mutex m_aMutex; // for m_aEventListeners }; } diff --git a/reportdesign/source/ui/misc/statusbarcontroller.cxx b/reportdesign/source/ui/misc/statusbarcontroller.cxx index 22f2d771412e..98310881a099 100644 --- a/reportdesign/source/ui/misc/statusbarcontroller.cxx +++ b/reportdesign/source/ui/misc/statusbarcontroller.cxx @@ -71,7 +71,6 @@ void SAL_CALL OStatusbarController::initialize( const Sequence< Any >& _rArgumen { StatusbarController::initialize(_rArguments); SolarMutexGuard aSolarMutexGuard; - ::osl::MutexGuard aGuard(m_aMutex); VclPtr< StatusBar > pStatusBar = static_cast<StatusBar*>(VCLUnoHelper::GetWindow(m_xParentWindow)); if ( !pStatusBar ) @@ -117,7 +116,6 @@ void SAL_CALL OStatusbarController::initialize( const Sequence< Any >& _rArgumen void SAL_CALL OStatusbarController::statusChanged( const FeatureStateEvent& _aEvent) { SolarMutexGuard aSolarGuard; - ::osl::MutexGuard aGuard(m_aMutex); if ( !m_rController.is() ) return; diff --git a/svtools/source/uno/statusbarcontroller.cxx b/svtools/source/uno/statusbarcontroller.cxx index 3bf6de2cf103..59607875ffc6 100644 --- a/svtools/source/uno/statusbarcontroller.cxx +++ b/svtools/source/uno/statusbarcontroller.cxx @@ -56,7 +56,6 @@ StatusbarController::StatusbarController( , m_xFrame( xFrame ) , m_xContext( rxContext ) , m_aCommandURL(std::move( aCommandURL )) - , m_aListenerContainer( m_aMutex ) { } @@ -65,7 +64,6 @@ StatusbarController::StatusbarController() : , m_bInitialized( false ) , m_bDisposed( false ) , m_nID( 0 ) - , m_aListenerContainer( m_aMutex ) { } @@ -182,8 +180,11 @@ void SAL_CALL StatusbarController::dispose() return; } - css::lang::EventObject aEvent( xThis ); - m_aListenerContainer.disposeAndClear( aEvent ); + { + std::unique_lock aGuard(m_aMutex); + css::lang::EventObject aEvent( xThis ); + m_aEventListeners.disposeAndClear( aGuard, aEvent ); + } SolarMutexGuard aSolarMutexGuard; Reference< XStatusListener > xStatusListener = this; @@ -220,12 +221,14 @@ void SAL_CALL StatusbarController::dispose() void SAL_CALL StatusbarController::addEventListener( const Reference< XEventListener >& xListener ) { - m_aListenerContainer.addInterface( cppu::UnoType<XEventListener>::get(), xListener ); + std::unique_lock aGuard(m_aMutex); + m_aEventListeners.addInterface( aGuard, xListener ); } -void SAL_CALL StatusbarController::removeEventListener( const Reference< XEventListener >& aListener ) +void SAL_CALL StatusbarController::removeEventListener( const Reference< XEventListener >& xListener ) { - m_aListenerContainer.removeInterface( cppu::UnoType<XEventListener>::get(), aListener ); + std::unique_lock aGuard(m_aMutex); + m_aEventListeners.removeInterface( aGuard, xListener ); } // XEventListener |