diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-12-22 20:06:20 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-12-24 08:21:00 +0100 |
commit | 252dd254b5b29298457b889623783152e9bed534 (patch) | |
tree | 07583e1f12bacc6ab8e40b35f4832c27076b84da /comphelper | |
parent | 54115790926a5964534472dff7e4661ea34acb28 (diff) |
new comphelper::WeakImplComponentHelper
to replace the cppu:: equivalent with a lightweight version
that uses std::mutex instead of osl::Mutex
Change-Id: I1b7873a0c2d9cda21f529e43a4ac2fa7574c91a5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127335
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/Library_comphelper.mk | 1 | ||||
-rw-r--r-- | comphelper/source/misc/compbase.cxx | 48 |
2 files changed, 49 insertions, 0 deletions
diff --git a/comphelper/Library_comphelper.mk b/comphelper/Library_comphelper.mk index 6bd5f0f6492d..20067b14b4ce 100644 --- a/comphelper/Library_comphelper.mk +++ b/comphelper/Library_comphelper.mk @@ -91,6 +91,7 @@ $(eval $(call gb_Library_add_exception_objects,comphelper,\ comphelper/source/misc/automationinvokedzone \ comphelper/source/misc/backupfilehelper \ comphelper/source/misc/base64 \ + comphelper/source/misc/compbase \ comphelper/source/misc/componentbase \ comphelper/source/misc/configuration \ comphelper/source/misc/configurationhelper \ diff --git a/comphelper/source/misc/compbase.cxx b/comphelper/source/misc/compbase.cxx new file mode 100644 index 000000000000..bd2ff837943f --- /dev/null +++ b/comphelper/source/misc/compbase.cxx @@ -0,0 +1,48 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <comphelper/compbase.hxx> + +namespace comphelper +{ +WeakComponentImplHelperBase::~WeakComponentImplHelperBase() {} + +// css::lang::XComponent +void SAL_CALL WeakComponentImplHelperBase::dispose() +{ + std::unique_lock aGuard(m_aMutex); + if (m_bDisposed) + return; + m_bDisposed = true; + disposing(); + css::lang::EventObject aEvt(static_cast<OWeakObject*>(this)); + maEventListeners.disposeAndClear(aGuard, aEvt); +} + +void WeakComponentImplHelperBase::disposing() {} + +void SAL_CALL WeakComponentImplHelperBase::addEventListener( + css::uno::Reference<css::lang::XEventListener> const& rxListener) +{ + std::unique_lock aGuard(m_aMutex); + if (m_bDisposed) + return; + maEventListeners.addInterface(rxListener); +} + +void SAL_CALL WeakComponentImplHelperBase::removeEventListener( + css::uno::Reference<css::lang::XEventListener> const& rxListener) +{ + std::unique_lock aGuard(m_aMutex); + maEventListeners.removeInterface(rxListener); +} + +} // namespace comphelper + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |