svtools/source/control/valueacc.cxx | 29 +++++++++++++---------------- svtools/source/control/valueimp.hxx | 11 ++++------- 2 files changed, 17 insertions(+), 23 deletions(-)
New commits: commit 35267be7ce33c5203a76e8023382c287b2e1f180 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Fri Dec 24 11:51:29 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sat Dec 25 16:52:14 2021 +0100 use comphelper::WeakComponentImplHelper in ValueSetAcc and remove unnecessary use of SolarMutex, the fields are already protected by mutex and the locked region doesn't call into vcl. Change-Id: Ia010674b14fafe2bfac27956af71fb557a4df212 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127408 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/svtools/source/control/valueacc.cxx b/svtools/source/control/valueacc.cxx index d8f97826499f..23d3dcde9bc6 100644 --- a/svtools/source/control/valueacc.cxx +++ b/svtools/source/control/valueacc.cxx @@ -418,7 +418,6 @@ void ValueItemAcc::FireAccessibleEvent( short nEventId, const uno::Any& rOldValu } ValueSetAcc::ValueSetAcc( ValueSet* pParent ) : - ValueSetAccComponentBase (m_aMutex), mpParent( pParent ), mbIsFocused(false) { @@ -661,7 +660,7 @@ lang::Locale SAL_CALL ValueSetAcc::getLocale() void SAL_CALL ValueSetAcc::addAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener ) { ThrowIfDisposed(); - ::osl::MutexGuard aGuard (m_aMutex); + std::unique_lock aGuard (m_aMutex); if( !rxListener.is() ) return; @@ -685,7 +684,7 @@ void SAL_CALL ValueSetAcc::addAccessibleEventListener( const uno::Reference< acc void SAL_CALL ValueSetAcc::removeAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener ) { ThrowIfDisposed(); - ::osl::MutexGuard aGuard (m_aMutex); + std::unique_lock aGuard (m_aMutex); if( rxListener.is() ) { @@ -911,21 +910,19 @@ sal_Int64 SAL_CALL ValueSetAcc::getSomething( const uno::Sequence< sal_Int8 >& r } -void SAL_CALL ValueSetAcc::disposing() +void ValueSetAcc::disposing(std::unique_lock<std::mutex>& rGuard) { - ::std::vector<uno::Reference<accessibility::XAccessibleEventListener> > aListenerListCopy; + // Make a copy of the list and clear the original. + ::std::vector<uno::Reference<accessibility::XAccessibleEventListener> > aListenerListCopy = std::move(mxEventListeners); - { - // Make a copy of the list and clear the original. - const SolarMutexGuard aSolarGuard; - ::osl::MutexGuard aGuard (m_aMutex); - aListenerListCopy.swap(mxEventListeners); - - // Reset the pointer to the parent. It has to be the one who has - // disposed us because he is dying. - mpParent = nullptr; - } + // Reset the pointer to the parent. It has to be the one who has + // disposed us because he is dying. + mpParent = nullptr; + + if (aListenerListCopy.empty()) + return; + rGuard.unlock(); // Inform all listeners that this objects is disposing. lang::EventObject aEvent (static_cast<accessibility::XAccessible*>(this)); for (auto const& listenerCopy : aListenerListCopy) @@ -974,7 +971,7 @@ ValueSetItem* ValueSetAcc::getItem (sal_uInt16 nIndex) const void ValueSetAcc::ThrowIfDisposed() { - if (rBHelper.bDisposed || rBHelper.bInDispose) + if (m_bDisposed) { SAL_WARN("svx", "Calling disposed object. Throwing exception:"); throw lang::DisposedException ( diff --git a/svtools/source/control/valueimp.hxx b/svtools/source/control/valueimp.hxx index ca25ddbc12cf..4f9e9ec9c945 100644 --- a/svtools/source/control/valueimp.hxx +++ b/svtools/source/control/valueimp.hxx @@ -23,8 +23,7 @@ #include <tools/color.hxx> #include <vcl/image.hxx> #include <cppuhelper/implbase.hxx> -#include <cppuhelper/compbase.hxx> -#include <cppuhelper/basemutex.hxx> +#include <comphelper/compbase.hxx> #include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/accessibility/XAccessible.hpp> #include <com/sun/star/accessibility/XAccessibleContext.hpp> @@ -68,7 +67,7 @@ struct ValueSetItem GetAccessible( bool bIsTransientChildrenDisabled ); }; -typedef ::cppu::WeakComponentImplHelper< +typedef comphelper::WeakComponentImplHelper< css::accessibility::XAccessible, css::accessibility::XAccessibleEventBroadcaster, css::accessibility::XAccessibleContext, @@ -77,9 +76,7 @@ typedef ::cppu::WeakComponentImplHelper< css::lang::XUnoTunnel > ValueSetAccComponentBase; -class ValueSetAcc : - public ::cppu::BaseMutex, - public ValueSetAccComponentBase +class ValueSetAcc final : public ValueSetAccComponentBase { public: @@ -156,7 +153,7 @@ private: /** Tell all listeners that the object is dying. This callback is usually called from the WeakComponentImplHelper class. */ - virtual void SAL_CALL disposing() override; + virtual void disposing(std::unique_lock<std::mutex>&) override; /** Return the number of items. This takes the None-Item into account. */