summaryrefslogtreecommitdiff
path: root/sfx2/source/appl/preventduplicateinteraction.cxx
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2019-04-07 11:48:47 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2019-04-07 17:53:04 +0200
commit5a824268dfdd48c00f656b767b48cd12ccbdaabb (patch)
treea25f4afd3ca49cff41fc44559aedea70c82e6c7e /sfx2/source/appl/preventduplicateinteraction.cxx
parenta6186a678cd9f67359da885606b3c3983f6bdc74 (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 'sfx2/source/appl/preventduplicateinteraction.cxx')
-rw-r--r--sfx2/source/appl/preventduplicateinteraction.cxx25
1 files changed, 7 insertions, 18 deletions
diff --git a/sfx2/source/appl/preventduplicateinteraction.cxx b/sfx2/source/appl/preventduplicateinteraction.cxx
index f9c38dd81132..3f34743891d3 100644
--- a/sfx2/source/appl/preventduplicateinteraction.cxx
+++ b/sfx2/source/appl/preventduplicateinteraction.cxx
@@ -41,20 +41,14 @@ PreventDuplicateInteraction::~PreventDuplicateInteraction()
void PreventDuplicateInteraction::setHandler(const css::uno::Reference< css::task::XInteractionHandler >& xHandler)
{
// SAFE ->
- ::osl::ResettableMutexGuard aLock(m_aLock);
+ osl::MutexGuard aLock(m_aLock);
m_xWarningDialogsParent.reset();
m_xHandler = xHandler;
- aLock.clear();
// <- SAFE
}
void PreventDuplicateInteraction::useDefaultUUIHandler()
{
- // SAFE ->
- ::osl::ResettableMutexGuard aLock(m_aLock);
- aLock.clear();
- // <- SAFE
-
//if we use the default handler, set the parent to a window belonging to this object so that the dialogs
//don't block unrelated windows.
m_xWarningDialogsParent.reset(new WarningDialogsParentScope(m_xContext));
@@ -62,9 +56,8 @@ void PreventDuplicateInteraction::useDefaultUUIHandler()
m_xContext, m_xWarningDialogsParent->GetDialogParent()), css::uno::UNO_QUERY_THROW);
// SAFE ->
- aLock.reset();
+ osl::MutexGuard aLock(m_aLock);
m_xHandler = xHandler;
- aLock.clear();
// <- SAFE
}
@@ -72,7 +65,7 @@ css::uno::Any SAL_CALL PreventDuplicateInteraction::queryInterface( const css::u
{
if ( aType.equals( cppu::UnoType<XInteractionHandler2>::get() ) )
{
- ::osl::ResettableMutexGuard aLock(m_aLock);
+ osl::MutexGuard aLock(m_aLock);
css::uno::Reference< css::task::XInteractionHandler2 > xHandler( m_xHandler, css::uno::UNO_QUERY );
if ( !xHandler.is() )
return css::uno::Any();
@@ -86,7 +79,7 @@ void SAL_CALL PreventDuplicateInteraction::handle(const css::uno::Reference< css
bool bHandleIt = true;
// SAFE ->
- ::osl::ResettableMutexGuard aLock(m_aLock);
+ osl::ClearableMutexGuard aLock(m_aLock);
auto pIt = std::find_if(m_lInteractionRules.begin(), m_lInteractionRules.end(),
[&aRequest](const InteractionInfo& rInfo) { return aRequest.isExtractableTo(rInfo.m_aInteraction); });
@@ -131,7 +124,7 @@ sal_Bool SAL_CALL PreventDuplicateInteraction::handleInteractionRequest( const c
bool bHandleIt = true;
// SAFE ->
- ::osl::ResettableMutexGuard aLock(m_aLock);
+ osl::ClearableMutexGuard aLock(m_aLock);
auto pIt = std::find_if(m_lInteractionRules.begin(), m_lInteractionRules.end(),
[&aRequest](const InteractionInfo& rInfo) { return aRequest.isExtractableTo(rInfo.m_aInteraction); });
@@ -176,7 +169,7 @@ sal_Bool SAL_CALL PreventDuplicateInteraction::handleInteractionRequest( const c
void PreventDuplicateInteraction::addInteractionRule(const PreventDuplicateInteraction::InteractionInfo& aInteractionInfo)
{
// SAFE ->
- ::osl::ResettableMutexGuard aLock(m_aLock);
+ osl::MutexGuard aLock(m_aLock);
auto pIt = std::find_if(m_lInteractionRules.begin(), m_lInteractionRules.end(),
[&aInteractionInfo](const InteractionInfo& rInfo) { return rInfo.m_aInteraction == aInteractionInfo.m_aInteraction; });
@@ -189,8 +182,6 @@ void PreventDuplicateInteraction::addInteractionRule(const PreventDuplicateInter
}
m_lInteractionRules.push_back(aInteractionInfo);
-
- aLock.clear();
// <- SAFE
}
@@ -198,7 +189,7 @@ bool PreventDuplicateInteraction::getInteractionInfo(const css::uno::Type&
PreventDuplicateInteraction::InteractionInfo* pReturn ) const
{
// SAFE ->
- ::osl::ResettableMutexGuard aLock(m_aLock);
+ osl::MutexGuard aLock(m_aLock);
auto pIt = std::find_if(m_lInteractionRules.begin(), m_lInteractionRules.end(),
[&aInteraction](const InteractionInfo& rInfo) { return rInfo.m_aInteraction == aInteraction; });
@@ -207,8 +198,6 @@ bool PreventDuplicateInteraction::getInteractionInfo(const css::uno::Type&
*pReturn = *pIt;
return true;
}
-
- aLock.clear();
// <- SAFE
return false;