diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-02-21 16:00:52 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-02-22 12:27:55 +0100 |
commit | 27352b81638f2f1e792ab48ec532eaacf6f61718 (patch) | |
tree | eb744c30643272b219d59f2782ffc96f62bf379c /cppuhelper | |
parent | 6ccdd0d164b16da9a13ab5d8290a1a0f041caaf7 (diff) |
Add XWeak constructor and operator= to uno::WeakReference
which is faster since we can skip the UNO_QUERY.
Change-Id: Id95ad9f3568213e974bd13659d92d4ea94dbfbd6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130282
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'cppuhelper')
-rw-r--r-- | cppuhelper/source/gcc3.map | 7 | ||||
-rw-r--r-- | cppuhelper/source/weak.cxx | 46 |
2 files changed, 53 insertions, 0 deletions
diff --git a/cppuhelper/source/gcc3.map b/cppuhelper/source/gcc3.map index d5af50655c1a..07099853afb7 100644 --- a/cppuhelper/source/gcc3.map +++ b/cppuhelper/source/gcc3.map @@ -435,6 +435,13 @@ global: _ZN3com3sun4star3uno19WeakReferenceHelperaSEOS3_; # com::sun::star::uno::WeakReferenceHelper::operator=(com::sun::star::uno::WeakReferenceHelper&&) } LIBO_UDK_3.9; +LIBO_UDK_7.5 { # LibO 7.5 +global: + _ZN3com3sun4star3uno19WeakReferenceHelperaSERKNS2_9ReferenceINS2_5XWeakEEE; # com::sun::star::uno::WeakReferenceHelper::operator=(com::sun::star::uno::Reference<com::sun::star::uno::XWeak> const&) + _ZN3com3sun4star3uno19WeakReferenceHelperC1ERKNS2_9ReferenceINS2_5XWeakEEE; # com::sun::star::uno::WeakReferenceHelper::WeakReferenceHelper(com::sun::star::uno::Reference<com::sun::star::uno::XWeak> const&) + _ZN3com3sun4star3uno19WeakReferenceHelperC2ERKNS2_9ReferenceINS2_5XWeakEEE; # com::sun::star::uno::WeakReferenceHelper::WeakReferenceHelper(com::sun::star::uno::Reference<com::sun::star::uno::XWeak> const&) +} LIBO_UDK_5.3; + # Unique libstdc++ symbols: GLIBCXX_3.4 { global: diff --git a/cppuhelper/source/weak.cxx b/cppuhelper/source/weak.cxx index f45f433e9ce2..65c9e7f81912 100644 --- a/cppuhelper/source/weak.cxx +++ b/cppuhelper/source/weak.cxx @@ -331,6 +331,7 @@ class OWeakRefListener final : public XReference { public: explicit OWeakRefListener(const Reference< XInterface >& xInt); + explicit OWeakRefListener(const Reference< XWeak >& xInt); virtual ~OWeakRefListener(); // noncopyable @@ -372,6 +373,25 @@ OWeakRefListener::OWeakRefListener(const Reference< XInterface >& xInt) osl_atomic_decrement( &m_aRefCount ); } +OWeakRefListener::OWeakRefListener(const Reference< XWeak >& xWeak) + : m_aRefCount( 1 ) +{ + try + { + if (xWeak.is()) + { + m_XWeakConnectionPoint = xWeak->queryAdapter(); + + if (m_XWeakConnectionPoint.is()) + { + m_XWeakConnectionPoint->addReference(static_cast<XReference*>(this)); + } + } + } + catch (RuntimeException &) { OSL_ASSERT( false ); } // assert here, but no unexpected() + osl_atomic_decrement( &m_aRefCount ); +} + OWeakRefListener::~OWeakRefListener() { try @@ -434,6 +454,16 @@ WeakReferenceHelper::WeakReferenceHelper(const Reference< XInterface >& xInt) } } +WeakReferenceHelper::WeakReferenceHelper(const Reference< XWeak >& xWeak) + : m_pImpl( nullptr ) +{ + if (xWeak.is()) + { + m_pImpl = new OWeakRefListener(xWeak); + m_pImpl->acquire(); + } +} + WeakReferenceHelper::WeakReferenceHelper(const WeakReferenceHelper& rWeakRef) : m_pImpl( nullptr ) { @@ -493,6 +523,22 @@ WeakReferenceHelper::operator= (const Reference< XInterface > & xInt) return *this; } +WeakReferenceHelper & +WeakReferenceHelper::operator= (const Reference< XWeak > & xWeak) +{ + try + { + clear(); + if (xWeak.is()) + { + m_pImpl = new OWeakRefListener(xWeak); + m_pImpl->acquire(); + } + } + catch (RuntimeException &) { OSL_ASSERT( false ); } // assert here, but no unexpected() + return *this; +} + WeakReferenceHelper::~WeakReferenceHelper() { clear(); |