diff options
author | Arnaud Versini <arnaud.versini@libreoffice.org> | 2021-10-24 19:41:36 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-11-04 20:23:25 +0100 |
commit | b439832fc36a05e4423f480f7a312428f2449cc6 (patch) | |
tree | b5cb997d6d38b4a75648a38e7921ab66f5178b34 /comphelper | |
parent | 4acc39564e7bf6051b851d533d67d1c31a4a19ea (diff) |
comphelper : use std::mutex in enumhelper
Change-Id: I871c406e8ff94e646545cb82e0d1e2e2ec80c6e9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124125
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/source/container/enumhelper.cxx | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/comphelper/source/container/enumhelper.cxx b/comphelper/source/container/enumhelper.cxx index edcb03c669cc..2487d3adf234 100644 --- a/comphelper/source/container/enumhelper.cxx +++ b/comphelper/source/container/enumhelper.cxx @@ -48,13 +48,15 @@ OEnumerationByName::OEnumerationByName(const css::uno::Reference<css::container: OEnumerationByName::~OEnumerationByName() { + std::lock_guard aLock(m_aLock); + impl_stopDisposeListening(); } sal_Bool SAL_CALL OEnumerationByName::hasMoreElements( ) { - osl::MutexGuard aLock(m_aLock); + std::lock_guard aLock(m_aLock); if (m_xAccess.is() && m_aNames.getLength() > m_nPos) return true; @@ -71,7 +73,7 @@ sal_Bool SAL_CALL OEnumerationByName::hasMoreElements( ) css::uno::Any SAL_CALL OEnumerationByName::nextElement( ) { - osl::MutexGuard aLock(m_aLock); + std::lock_guard aLock(m_aLock); css::uno::Any aRes; if (m_xAccess.is() && m_nPos < m_aNames.getLength()) @@ -92,7 +94,7 @@ css::uno::Any SAL_CALL OEnumerationByName::nextElement( ) void SAL_CALL OEnumerationByName::disposing(const css::lang::EventObject& aEvent) { - osl::MutexGuard aLock(m_aLock); + std::lock_guard aLock(m_aLock); if (aEvent.Source == m_xAccess) m_xAccess.clear(); @@ -101,8 +103,6 @@ void SAL_CALL OEnumerationByName::disposing(const css::lang::EventObject& aEvent void OEnumerationByName::impl_startDisposeListening() { - osl::MutexGuard aLock(m_aLock); - if (m_bListening) return; @@ -119,8 +119,6 @@ void OEnumerationByName::impl_startDisposeListening() void OEnumerationByName::impl_stopDisposeListening() { - osl::MutexGuard aLock(m_aLock); - if (!m_bListening) return; @@ -145,13 +143,15 @@ OEnumerationByIndex::OEnumerationByIndex(const css::uno::Reference< css::contain OEnumerationByIndex::~OEnumerationByIndex() { + std::lock_guard aLock(m_aLock); + impl_stopDisposeListening(); } sal_Bool SAL_CALL OEnumerationByIndex::hasMoreElements( ) { - osl::MutexGuard aLock(m_aLock); + std::lock_guard aLock(m_aLock); if (m_xAccess.is() && m_xAccess->getCount() > m_nPos) return true; @@ -168,7 +168,7 @@ sal_Bool SAL_CALL OEnumerationByIndex::hasMoreElements( ) css::uno::Any SAL_CALL OEnumerationByIndex::nextElement( ) { - osl::MutexGuard aLock(m_aLock); + std::lock_guard aLock(m_aLock); css::uno::Any aRes; if (m_xAccess.is() && m_nPos < m_xAccess->getCount()) @@ -188,7 +188,7 @@ css::uno::Any SAL_CALL OEnumerationByIndex::nextElement( ) void SAL_CALL OEnumerationByIndex::disposing(const css::lang::EventObject& aEvent) { - osl::MutexGuard aLock(m_aLock); + std::lock_guard aLock(m_aLock); if (aEvent.Source == m_xAccess) m_xAccess.clear(); @@ -197,8 +197,6 @@ void SAL_CALL OEnumerationByIndex::disposing(const css::lang::EventObject& aEven void OEnumerationByIndex::impl_startDisposeListening() { - osl::MutexGuard aLock(m_aLock); - if (m_bListening) return; @@ -215,8 +213,6 @@ void OEnumerationByIndex::impl_startDisposeListening() void OEnumerationByIndex::impl_stopDisposeListening() { - osl::MutexGuard aLock(m_aLock); - if (!m_bListening) return; @@ -244,7 +240,7 @@ OAnyEnumeration::~OAnyEnumeration() sal_Bool SAL_CALL OAnyEnumeration::hasMoreElements( ) { - osl::MutexGuard aLock(m_aLock); + std::lock_guard aLock(m_aLock); return (m_lItems.getLength() > m_nPos); } @@ -255,7 +251,7 @@ css::uno::Any SAL_CALL OAnyEnumeration::nextElement( ) if ( ! hasMoreElements()) throw css::container::NoSuchElementException(); - osl::MutexGuard aLock(m_aLock); + std::lock_guard aLock(m_aLock); sal_Int32 nPos = m_nPos; ++m_nPos; return m_lItems[nPos]; |