Skip to content

Commit 35267be

Browse files
grandinjNoel Grandin
authored and
Noel Grandin
committed
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 <[email protected]>
1 parent eb40074 commit 35267be

File tree

2 files changed

+17
-23
lines changed

2 files changed

+17
-23
lines changed

svtools/source/control/valueacc.cxx

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,6 @@ void ValueItemAcc::FireAccessibleEvent( short nEventId, const uno::Any& rOldValu
418418
}
419419

420420
ValueSetAcc::ValueSetAcc( ValueSet* pParent ) :
421-
ValueSetAccComponentBase (m_aMutex),
422421
mpParent( pParent ),
423422
mbIsFocused(false)
424423
{
@@ -661,7 +660,7 @@ lang::Locale SAL_CALL ValueSetAcc::getLocale()
661660
void SAL_CALL ValueSetAcc::addAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
662661
{
663662
ThrowIfDisposed();
664-
::osl::MutexGuard aGuard (m_aMutex);
663+
std::unique_lock aGuard (m_aMutex);
665664

666665
if( !rxListener.is() )
667666
return;
@@ -685,7 +684,7 @@ void SAL_CALL ValueSetAcc::addAccessibleEventListener( const uno::Reference< acc
685684
void SAL_CALL ValueSetAcc::removeAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
686685
{
687686
ThrowIfDisposed();
688-
::osl::MutexGuard aGuard (m_aMutex);
687+
std::unique_lock aGuard (m_aMutex);
689688

690689
if( rxListener.is() )
691690
{
@@ -911,21 +910,19 @@ sal_Int64 SAL_CALL ValueSetAcc::getSomething( const uno::Sequence< sal_Int8 >& r
911910
}
912911

913912

914-
void SAL_CALL ValueSetAcc::disposing()
913+
void ValueSetAcc::disposing(std::unique_lock<std::mutex>& rGuard)
915914
{
916-
::std::vector<uno::Reference<accessibility::XAccessibleEventListener> > aListenerListCopy;
915+
// Make a copy of the list and clear the original.
916+
::std::vector<uno::Reference<accessibility::XAccessibleEventListener> > aListenerListCopy = std::move(mxEventListeners);
917917

918-
{
919-
// Make a copy of the list and clear the original.
920-
const SolarMutexGuard aSolarGuard;
921-
::osl::MutexGuard aGuard (m_aMutex);
922-
aListenerListCopy.swap(mxEventListeners);
923-
924-
// Reset the pointer to the parent. It has to be the one who has
925-
// disposed us because he is dying.
926-
mpParent = nullptr;
927-
}
918+
// Reset the pointer to the parent. It has to be the one who has
919+
// disposed us because he is dying.
920+
mpParent = nullptr;
921+
922+
if (aListenerListCopy.empty())
923+
return;
928924

925+
rGuard.unlock();
929926
// Inform all listeners that this objects is disposing.
930927
lang::EventObject aEvent (static_cast<accessibility::XAccessible*>(this));
931928
for (auto const& listenerCopy : aListenerListCopy)
@@ -974,7 +971,7 @@ ValueSetItem* ValueSetAcc::getItem (sal_uInt16 nIndex) const
974971

975972
void ValueSetAcc::ThrowIfDisposed()
976973
{
977-
if (rBHelper.bDisposed || rBHelper.bInDispose)
974+
if (m_bDisposed)
978975
{
979976
SAL_WARN("svx", "Calling disposed object. Throwing exception:");
980977
throw lang::DisposedException (

svtools/source/control/valueimp.hxx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
#include <tools/color.hxx>
2424
#include <vcl/image.hxx>
2525
#include <cppuhelper/implbase.hxx>
26-
#include <cppuhelper/compbase.hxx>
27-
#include <cppuhelper/basemutex.hxx>
26+
#include <comphelper/compbase.hxx>
2827
#include <com/sun/star/lang/XUnoTunnel.hpp>
2928
#include <com/sun/star/accessibility/XAccessible.hpp>
3029
#include <com/sun/star/accessibility/XAccessibleContext.hpp>
@@ -68,7 +67,7 @@ struct ValueSetItem
6867
GetAccessible( bool bIsTransientChildrenDisabled );
6968
};
7069

71-
typedef ::cppu::WeakComponentImplHelper<
70+
typedef comphelper::WeakComponentImplHelper<
7271
css::accessibility::XAccessible,
7372
css::accessibility::XAccessibleEventBroadcaster,
7473
css::accessibility::XAccessibleContext,
@@ -77,9 +76,7 @@ typedef ::cppu::WeakComponentImplHelper<
7776
css::lang::XUnoTunnel >
7877
ValueSetAccComponentBase;
7978

80-
class ValueSetAcc :
81-
public ::cppu::BaseMutex,
82-
public ValueSetAccComponentBase
79+
class ValueSetAcc final : public ValueSetAccComponentBase
8380
{
8481
public:
8582

@@ -156,7 +153,7 @@ private:
156153
/** Tell all listeners that the object is dying. This callback is
157154
usually called from the WeakComponentImplHelper class.
158155
*/
159-
virtual void SAL_CALL disposing() override;
156+
virtual void disposing(std::unique_lock<std::mutex>&) override;
160157

161158
/** Return the number of items. This takes the None-Item into account.
162159
*/

0 commit comments

Comments
 (0)