diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2019-04-07 11:48:47 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2019-04-07 17:53:04 +0200 |
commit | 5a824268dfdd48c00f656b767b48cd12ccbdaabb (patch) | |
tree | a25f4afd3ca49cff41fc44559aedea70c82e6c7e /dtrans/source | |
parent | a6186a678cd9f67359da885606b3c3983f6bdc74 (diff) |
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 <mike.kaganski@collabora.com>
Diffstat (limited to 'dtrans/source')
-rw-r--r-- | dtrans/source/win32/clipb/MtaOleClipb.cxx | 4 | ||||
-rw-r--r-- | dtrans/source/win32/clipb/WinClipbImpl.cxx | 41 |
2 files changed, 22 insertions, 23 deletions
diff --git a/dtrans/source/win32/clipb/MtaOleClipb.cxx b/dtrans/source/win32/clipb/MtaOleClipb.cxx index 8b1b07ec7ecd..ea9f6dfb380f 100644 --- a/dtrans/source/win32/clipb/MtaOleClipb.cxx +++ b/dtrans/source/win32/clipb/MtaOleClipb.cxx @@ -494,12 +494,10 @@ LRESULT CMtaOleClipboard::onClipboardUpdate() // registering ourself as clipboard if ( !m_bInRegisterClipViewer ) { - ClearableMutexGuard aGuard( m_ClipboardChangedEventCountMutex ); + MutexGuard aGuard( m_ClipboardChangedEventCountMutex ); m_ClipboardChangedEventCount++; SetEvent( m_hClipboardChangedEvent ); - - aGuard.clear( ); } return 0; diff --git a/dtrans/source/win32/clipb/WinClipbImpl.cxx b/dtrans/source/win32/clipb/WinClipbImpl.cxx index 8df5db4a7d03..7ba04d13c4d8 100644 --- a/dtrans/source/win32/clipb/WinClipbImpl.cxx +++ b/dtrans/source/win32/clipb/WinClipbImpl.cxx @@ -63,9 +63,10 @@ CWinClipbImpl::CWinClipbImpl( const OUString& aClipboardName, CWinClipboard* the CWinClipbImpl::~CWinClipbImpl( ) { - ClearableMutexGuard aGuard( s_aMutex ); - s_pCWinClipbImpl = nullptr; - aGuard.clear( ); + { + MutexGuard aGuard(s_aMutex); + s_pCWinClipbImpl = nullptr; + } unregisterClipboardViewer( ); } @@ -74,16 +75,17 @@ Reference< XTransferable > CWinClipbImpl::getContents( ) { // use the shortcut or create a transferable from // system clipboard - ClearableMutexGuard aGuard( m_ClipContentMutex ); - - if ( nullptr != m_pCurrentClipContent ) { - return m_pCurrentClipContent->m_XTransferable; - } + MutexGuard aGuard(m_ClipContentMutex); - // release the mutex, so that the variable may be - // changed by other threads - aGuard.clear( ); + if (nullptr != m_pCurrentClipContent) + { + return m_pCurrentClipContent->m_XTransferable; + } + + // release the mutex, so that the variable may be + // changed by other threads + } Reference< XTransferable > rClipContent; @@ -112,15 +114,14 @@ void CWinClipbImpl::setContents( if ( xTransferable.is( ) ) { - ClearableMutexGuard aGuard( m_ClipContentMutex ); - - m_pCurrentClipContent = new CXNotifyingDataObject( - CDTransObjFactory::createDataObjFromTransferable( m_pWinClipboard->m_xContext , xTransferable ), - xTransferable, - xClipboardOwner, - this ); - - aGuard.clear( ); + { + MutexGuard aGuard(m_ClipContentMutex); + + m_pCurrentClipContent + = new CXNotifyingDataObject(CDTransObjFactory::createDataObjFromTransferable( + m_pWinClipboard->m_xContext, xTransferable), + xTransferable, xClipboardOwner, this); + } pIDataObj = IDataObjectPtr( m_pCurrentClipContent ); } |