sfx2/source/appl/shutdownicon.cxx | 13 ++++++------- sfx2/source/appl/shutdownicon.hxx | 8 +++----- sfx2/source/appl/shutdowniconaqua.mm | 1 + sfx2/source/control/thumbnailviewacc.cxx | 22 +++++++++++++--------- sfx2/source/control/thumbnailviewacc.hxx | 9 +++------ 5 files changed, 26 insertions(+), 27 deletions(-)
New commits: commit ad492932e9b64991001a0eb5e0aa1fa7801bb3fa Author: Noel Grandin <[email protected]> AuthorDate: Sat Dec 25 19:04:05 2021 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Mon Dec 27 07:34:57 2021 +0100 use comphelper::WeakComponentImplHelper in ShutdownIcon Change-Id: I1cb6292e981948e9a1ff9ce339d037540ade9614 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127525 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/sfx2/source/appl/shutdownicon.cxx b/sfx2/source/appl/shutdownicon.cxx index 8d221e07d90e..fd81eb41837b 100644 --- a/sfx2/source/appl/shutdownicon.cxx +++ b/sfx2/source/appl/shutdownicon.cxx @@ -140,7 +140,6 @@ void ShutdownIcon::deInitSystray() ShutdownIcon::ShutdownIcon( const css::uno::Reference< XComponentContext > & rxContext ) : - ShutdownIconServiceBase( m_aMutex ), m_bVeto ( false ), m_bListenForTermination ( false ), m_bSystemDialogs( false ), @@ -466,12 +465,12 @@ ShutdownIcon* ShutdownIcon::createInstance() void ShutdownIcon::init() { css::uno::Reference < XDesktop2 > xDesktop = Desktop::create( m_xContext ); - osl::MutexGuard aGuard(m_aMutex); + std::unique_lock aGuard(m_aMutex); m_xDesktop = xDesktop; } -void SAL_CALL ShutdownIcon::disposing() +void ShutdownIcon::disposing(std::unique_lock<std::mutex>&) { m_xContext.clear(); m_xDesktop.clear(); @@ -490,7 +489,7 @@ void SAL_CALL ShutdownIcon::disposing( const css::lang::EventObject& ) void SAL_CALL ShutdownIcon::queryTermination( const css::lang::EventObject& ) { SAL_INFO("sfx.appl", "ShutdownIcon::queryTermination: veto is " << m_bVeto); - osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); if ( m_bVeto ) throw css::frame::TerminationVetoException(); @@ -504,7 +503,7 @@ void SAL_CALL ShutdownIcon::notifyTermination( const css::lang::EventObject& ) void SAL_CALL ShutdownIcon::initialize( const css::uno::Sequence< css::uno::Any>& aArguments ) { - ::osl::ResettableMutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); // third argument only sets veto, everything else will be ignored! if (aArguments.getLength() > 2) @@ -523,9 +522,9 @@ void SAL_CALL ShutdownIcon::initialize( const css::uno::Sequence< css::uno::Any> bool bQuickstart = ::cppu::any2bool( aArguments[0] ); if( !bQuickstart && !GetAutostart() ) return; - aGuard.clear(); + aGuard.unlock(); init (); - aGuard.reset(); + aGuard.lock(); if ( !m_xDesktop.is() ) return; diff --git a/sfx2/source/appl/shutdownicon.hxx b/sfx2/source/appl/shutdownicon.hxx index 32113cbc1ee2..cb352e60b443 100644 --- a/sfx2/source/appl/shutdownicon.hxx +++ b/sfx2/source/appl/shutdownicon.hxx @@ -28,8 +28,7 @@ #include <com/sun/star/uno/XComponentContext.hpp> #include <rtl/ustring.hxx> #include <rtl/ref.hxx> -#include <osl/mutex.hxx> -#include <cppuhelper/compbase.hxx> +#include <comphelper/compbase.hxx> #include <tools/link.hxx> #include <memory> @@ -45,7 +44,7 @@ namespace sfx2 class FileDialogHelper; } -typedef ::cppu::WeakComponentImplHelper< +typedef comphelper::WeakComponentImplHelper< css::lang::XInitialization, css::frame::XTerminateListener, css::lang::XServiceInfo, @@ -62,7 +61,6 @@ typedef ::cppu::WeakComponentImplHelper< class ShutdownIcon : public ShutdownIconServiceBase { - ::osl::Mutex m_aMutex; bool m_bVeto; bool m_bListenForTermination; bool m_bSystemDialogs; @@ -120,7 +118,7 @@ class ShutdownIcon : public ShutdownIconServiceBase static bool IsQuickstarterInstalled(); // Component Helper - force override - virtual void SAL_CALL disposing() override; + virtual void disposing(std::unique_lock<std::mutex>&) override; // XEventListener virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; diff --git a/sfx2/source/appl/shutdowniconaqua.mm b/sfx2/source/appl/shutdowniconaqua.mm index 7e8bf071c95f..74a9602e6ce1 100644 --- a/sfx2/source/appl/shutdowniconaqua.mm +++ b/sfx2/source/appl/shutdowniconaqua.mm @@ -24,6 +24,7 @@ #include <rtl/ustring.hxx> #include <tools/urlobj.hxx> #include <osl/file.h> +#include <osl/diagnose.h> #include <comphelper/sequenceashashmap.hxx> #include <sfx2/app.hxx> #include <sal/macros.h> commit 26048e4f37cc0c595dc25dd07698aad82180fb3e Author: Noel Grandin <[email protected]> AuthorDate: Sat Dec 25 19:07:50 2021 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Mon Dec 27 07:34:44 2021 +0100 use comphelper::WeakComponentImplHelper in ThumbnailViewAcc Change-Id: I0a9aa7fac5efd8c91fdcca39882895171aeaf71f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127526 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> 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. */
