summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-01-20 13:11:21 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-01-23 07:56:34 +0200
commit017911facd7bf66bd8743e1d3357c2808dcd1bba (patch)
tree323845409416e22b8b679392897a042646a80672
parent45e591e237ef294ffd1a0f4a51122a748fd1460a (diff)
use rtl::Reference in OPropertyChangeListener
instead of manual acquire/release Change-Id: Ie80253b5a59a3e3fcd52f98d9c26bcde42fe985a
-rw-r--r--comphelper/source/property/propmultiplex.cxx25
-rw-r--r--include/comphelper/propmultiplex.hxx5
2 files changed, 10 insertions, 20 deletions
diff --git a/comphelper/source/property/propmultiplex.cxx b/comphelper/source/property/propmultiplex.cxx
index 4a50e8c283f6..e10d85a0c343 100644
--- a/comphelper/source/property/propmultiplex.cxx
+++ b/comphelper/source/property/propmultiplex.cxx
@@ -31,8 +31,8 @@ using namespace ::com::sun::star::beans;
OPropertyChangeListener::~OPropertyChangeListener()
{
- if (m_pAdapter)
- m_pAdapter->dispose();
+ if (m_xAdapter.is())
+ m_xAdapter->dispose();
}
@@ -45,29 +45,18 @@ void OPropertyChangeListener::_disposing(const EventObject&)
void OPropertyChangeListener::disposeAdapter()
{
- if ( m_pAdapter )
- m_pAdapter->dispose();
+ if ( m_xAdapter.is() )
+ m_xAdapter->dispose();
// will automatically set a new adapter
- OSL_ENSURE( !m_pAdapter, "OPropertyChangeListener::disposeAdapter: what did dispose do?" );
+ OSL_ENSURE( !m_xAdapter.is(), "OPropertyChangeListener::disposeAdapter: what did dispose do?" );
}
void OPropertyChangeListener::setAdapter(OPropertyChangeMultiplexer* pAdapter)
{
- if (m_pAdapter)
- {
- ::osl::MutexGuard aGuard(m_rMutex);
- m_pAdapter->release();
- m_pAdapter = nullptr;
- }
-
- if (pAdapter)
- {
- ::osl::MutexGuard aGuard(m_rMutex);
- m_pAdapter = pAdapter;
- m_pAdapter->acquire();
- }
+ ::osl::MutexGuard aGuard(m_rMutex);
+ m_xAdapter = pAdapter;
}
OPropertyChangeMultiplexer::OPropertyChangeMultiplexer(OPropertyChangeListener* _pListener, const Reference< XPropertySet>& _rxSet, bool _bAutoReleaseSet)
diff --git a/include/comphelper/propmultiplex.hxx b/include/comphelper/propmultiplex.hxx
index 628a809c157e..94edcda9d196 100644
--- a/include/comphelper/propmultiplex.hxx
+++ b/include/comphelper/propmultiplex.hxx
@@ -23,6 +23,7 @@
#include <comphelper/propstate.hxx>
#include <cppuhelper/implbase.hxx>
#include <comphelper/comphelperdllapi.h>
+#include <rtl/ref.hxx>
//= property helper classes
@@ -42,12 +43,12 @@ namespace comphelper
{
friend class OPropertyChangeMultiplexer;
- OPropertyChangeMultiplexer* m_pAdapter;
+ rtl::Reference<OPropertyChangeMultiplexer> m_xAdapter;
::osl::Mutex& m_rMutex;
public:
OPropertyChangeListener(::osl::Mutex& _rMutex)
- : m_pAdapter(nullptr), m_rMutex(_rMutex) { }
+ : m_rMutex(_rMutex) { }
virtual ~OPropertyChangeListener();
/// @throws css::uno::RuntimeException