summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-01-16 10:36:39 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-01-17 07:53:33 +0000
commitee2bd1ee97194f4d39d4d6ab95c9b926b5077cb8 (patch)
tree50256979facc16e390c72be94337ee31d5d38377
parentc815b89997cfa3ca875406887a33631f8cf50f19 (diff)
use rtl::Reference in OInstanceLocker
no need to store a raw pointer and a refcount pointer Change-Id: I2dc3b87dd870c8d8128c2249a18fda30319ba08c Reviewed-on: https://gerrit.libreoffice.org/33157 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--comphelper/source/misc/instancelocker.cxx14
-rw-r--r--comphelper/source/misc/instancelocker.hxx4
2 files changed, 6 insertions, 12 deletions
diff --git a/comphelper/source/misc/instancelocker.cxx b/comphelper/source/misc/instancelocker.cxx
index 11bc0e18836c..e6a39e876c93 100644
--- a/comphelper/source/misc/instancelocker.cxx
+++ b/comphelper/source/misc/instancelocker.cxx
@@ -38,8 +38,7 @@ using namespace ::com::sun::star;
OInstanceLocker::OInstanceLocker()
-: m_pLockListener( nullptr )
-, m_pListenersContainer( nullptr )
+: m_pListenersContainer( nullptr )
, m_bDisposed( false )
, m_bInitialized( false )
{
@@ -81,11 +80,7 @@ void SAL_CALL OInstanceLocker::dispose()
if ( m_xLockListener.is() )
{
- if ( m_pLockListener )
- {
- m_pLockListener->Dispose();
- m_pLockListener = nullptr;
- }
+ m_xLockListener->Dispose();
m_xLockListener.clear();
}
@@ -169,12 +164,11 @@ void SAL_CALL OInstanceLocker::initialize( const uno::Sequence< uno::Any >& aArg
uno::Reference< uno::XInterface >(),
0 );
- m_pLockListener = new OLockListener( uno::Reference< lang::XComponent > ( static_cast< lang::XComponent* >( this ) ),
+ m_xLockListener = new OLockListener( uno::Reference< lang::XComponent > ( static_cast< lang::XComponent* >( this ) ),
xInstance,
nModes,
xApproval );
- m_xLockListener.set( static_cast< OWeakObject* >( m_pLockListener ) );
- m_pLockListener->Init();
+ m_xLockListener->Init();
}
catch( uno::Exception& )
{
diff --git a/comphelper/source/misc/instancelocker.hxx b/comphelper/source/misc/instancelocker.hxx
index 6960e1da60ef..df6c39cedd7a 100644
--- a/comphelper/source/misc/instancelocker.hxx
+++ b/comphelper/source/misc/instancelocker.hxx
@@ -32,6 +32,7 @@
#include <osl/mutex.hxx>
#include <cppuhelper/implbase.hxx>
#include <comphelper/interfacecontainer2.hxx>
+#include <rtl/ref.hxx>
class OLockListener;
@@ -44,8 +45,7 @@ class OInstanceLocker : public ::cppu::WeakImplHelper< css::lang::XComponent,
{
::osl::Mutex m_aMutex;
- css::uno::Reference< css::uno::XInterface > m_xLockListener;
- OLockListener* m_pLockListener;
+ rtl::Reference< OLockListener > m_xLockListener;
::comphelper::OInterfaceContainerHelper2* m_pListenersContainer; // list of listeners