summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2021-12-25 19:07:50 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-12-27 07:34:44 +0100
commit26048e4f37cc0c595dc25dd07698aad82180fb3e (patch)
tree537f9676126d7d9407558d8e51aa6bf0a2626525 /sfx2
parent174b39754e45f4df0e0123336f3ed298bf81ebc4 (diff)
use comphelper::WeakComponentImplHelper in ThumbnailViewAcc
Change-Id: I0a9aa7fac5efd8c91fdcca39882895171aeaf71f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127526 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/control/thumbnailviewacc.cxx22
-rw-r--r--sfx2/source/control/thumbnailviewacc.hxx9
2 files changed, 16 insertions, 15 deletions
diff --git a/sfx2/source/control/thumbnailviewacc.cxx b/sfx2/source/control/thumbnailviewacc.cxx
index 8ec4e0098872..4492980ccb9f 100644
--- a/sfx2/source/control/thumbnailviewacc.cxx
+++ b/sfx2/source/control/thumbnailviewacc.cxx
@@ -37,7 +37,6 @@
using namespace ::com::sun::star;
ThumbnailViewAcc::ThumbnailViewAcc( ThumbnailView* pParent ) :
- ValueSetAccComponentBase (m_aMutex),
mpParent( pParent )
{
}
@@ -207,7 +206,7 @@ lang::Locale SAL_CALL ThumbnailViewAcc::getLocale()
void SAL_CALL ThumbnailViewAcc::addAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
{
ThrowIfDisposed();
- ::osl::MutexGuard aGuard (m_aMutex);
+ std::unique_lock aGuard (m_aMutex);
if( !rxListener.is() )
return;
@@ -230,7 +229,7 @@ void SAL_CALL ThumbnailViewAcc::addAccessibleEventListener( const uno::Reference
void SAL_CALL ThumbnailViewAcc::removeAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
{
ThrowIfDisposed();
- ::osl::MutexGuard aGuard (m_aMutex);
+ std::unique_lock aGuard (m_aMutex);
if( rxListener.is() )
{
@@ -442,20 +441,25 @@ sal_Int64 SAL_CALL ThumbnailViewAcc::getSomething( const uno::Sequence< sal_Int8
return comphelper::getSomethingImpl(rId, this);
}
-void SAL_CALL ThumbnailViewAcc::disposing()
+void ThumbnailViewAcc::disposing(std::unique_lock<std::mutex>& rGuard)
{
::std::vector<uno::Reference<accessibility::XAccessibleEventListener> > aListenerListCopy;
+ // unlock because we need to take solar and the lock mutex in the correct order
+ rGuard.unlock();
{
- // Make a copy of the list and clear the original.
const SolarMutexGuard aSolarGuard;
- ::osl::MutexGuard aGuard (m_aMutex);
- aListenerListCopy = mxEventListeners;
- mxEventListeners.clear();
+ std::unique_lock aGuard (m_aMutex);
// Reset the pointer to the parent. It has to be the one who has
// disposed us because he is dying.
mpParent = nullptr;
+
+ if (mxEventListeners.empty())
+ return;
+
+ // Make a copy of the list and clear the original.
+ aListenerListCopy = std::move(mxEventListeners);
}
// Inform all listeners that this objects is disposing.
@@ -485,7 +489,7 @@ ThumbnailViewItem* ThumbnailViewAcc::getItem (sal_uInt16 nIndex) const
void ThumbnailViewAcc::ThrowIfDisposed()
{
- if (rBHelper.bDisposed || rBHelper.bInDispose)
+ if (m_bDisposed)
{
SAL_WARN("sfx", "Calling disposed object. Throwing exception:");
throw lang::DisposedException (
diff --git a/sfx2/source/control/thumbnailviewacc.hxx b/sfx2/source/control/thumbnailviewacc.hxx
index 2e31843d6438..5bde610b0831 100644
--- a/sfx2/source/control/thumbnailviewacc.hxx
+++ b/sfx2/source/control/thumbnailviewacc.hxx
@@ -21,8 +21,7 @@
#define INCLUDED_SFX2_SOURCE_CONTROL_THUMBNAILVIEWACC_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>
@@ -31,14 +30,13 @@
#include <com/sun/star/accessibility/XAccessibleSelection.hpp>
#include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
-#include <mutex>
#include <vcl/vclptr.hxx>
#include <vector>
class ThumbnailView;
class ThumbnailViewItem;
-typedef ::cppu::WeakComponentImplHelper<
+typedef comphelper::WeakComponentImplHelper<
css::accessibility::XAccessible,
css::accessibility::XAccessibleEventBroadcaster,
css::accessibility::XAccessibleContext,
@@ -48,7 +46,6 @@ typedef ::cppu::WeakComponentImplHelper<
ValueSetAccComponentBase;
class ThumbnailViewAcc :
- public ::cppu::BaseMutex,
public ValueSetAccComponentBase
{
public:
@@ -126,7 +123,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.
*/