From 5a824268dfdd48c00f656b767b48cd12ccbdaabb Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Sun, 7 Apr 2019 11:48:47 +0300 Subject: Don't use resettable/clearable guard where plain guard is enough Also use scope where possible. This allows to limit guard scope at language level; visualises the scope clearly; and helps avoiding errors like fixed in commit 61e4437c857854b331fa01da6f39b2b3b58a800b. Change-Id: Ifeca96e2df8e8a0897770d9546b2536806275f41 Reviewed-on: https://gerrit.libreoffice.org/70376 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- svtools/source/config/itemholder2.cxx | 4 ++-- svtools/source/misc/acceleratorexecute.cxx | 4 ++-- svtools/source/uno/popupmenucontrollerbase.cxx | 14 ++++++++------ 3 files changed, 12 insertions(+), 10 deletions(-) (limited to 'svtools') diff --git a/svtools/source/config/itemholder2.cxx b/svtools/source/config/itemholder2.cxx index c6b1034618ba..cbd78826d7c0 100644 --- a/svtools/source/config/itemholder2.cxx +++ b/svtools/source/config/itemholder2.cxx @@ -90,7 +90,7 @@ void SAL_CALL ItemHolder2::disposing(const css::lang::EventObject&) void ItemHolder2::impl_addItem(EItem eItem) { - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); for ( auto const & rInfo : m_lItems ) { @@ -110,7 +110,7 @@ void ItemHolder2::impl_releaseAllItems() { std::vector items; { - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); items.swap(m_lItems); } diff --git a/svtools/source/misc/acceleratorexecute.cxx b/svtools/source/misc/acceleratorexecute.cxx index 8ecfd2d64680..65632e04cb07 100644 --- a/svtools/source/misc/acceleratorexecute.cxx +++ b/svtools/source/misc/acceleratorexecute.cxx @@ -182,7 +182,7 @@ bool AcceleratorExecute::execute(const css::awt::KeyEvent& aAWTKey) } // SAFE -> ---------------------------------- - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::ClearableMutexGuard aLock(m_aLock); css::uno::Reference< css::frame::XDispatchProvider > xProvider = m_xDispatcher; @@ -247,7 +247,7 @@ OUString AcceleratorExecute::findCommand(const css::awt::KeyEvent& aKey) OUString AcceleratorExecute::impl_ts_findCommand(const css::awt::KeyEvent& aKey) { // SAFE -> ---------------------------------- - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::ClearableMutexGuard aLock(m_aLock); css::uno::Reference< css::ui::XAcceleratorConfiguration > xGlobalCfg = m_xGlobalCfg; css::uno::Reference< css::ui::XAcceleratorConfiguration > xModuleCfg = m_xModuleCfg; diff --git a/svtools/source/uno/popupmenucontrollerbase.cxx b/svtools/source/uno/popupmenucontrollerbase.cxx index 8bf253442d55..9ce87c67c0af 100644 --- a/svtools/source/uno/popupmenucontrollerbase.cxx +++ b/svtools/source/uno/popupmenucontrollerbase.cxx @@ -167,9 +167,10 @@ void SAL_CALL PopupMenuControllerBase::itemDeactivated( const awt::MenuEvent& ) void SAL_CALL PopupMenuControllerBase::updatePopupMenu() { - osl::ClearableMutexGuard aLock( m_aMutex ); - throwIfDisposed(); - aLock.clear(); + { + osl::MutexGuard aLock(m_aMutex); + throwIfDisposed(); + } updateCommand( m_aCommandURL ); } @@ -211,9 +212,10 @@ Sequence< Reference< XDispatch > > SAL_CALL PopupMenuControllerBase::queryDispat { // Create return list - which must have same size then the given descriptor // It's not allowed to pack it! - osl::ClearableMutexGuard aLock( m_aMutex ); - throwIfDisposed(); - aLock.clear(); + { + osl::MutexGuard aLock(m_aMutex); + throwIfDisposed(); + } sal_Int32 nCount = lDescriptor.getLength(); uno::Sequence< uno::Reference< frame::XDispatch > > lDispatcher( nCount ); -- cgit