summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--comphelper/source/container/containermultiplexer.cxx23
-rw-r--r--include/comphelper/containermultiplexer.hxx5
2 files changed, 8 insertions, 20 deletions
diff --git a/comphelper/source/container/containermultiplexer.cxx b/comphelper/source/container/containermultiplexer.cxx
index b7e3c93becbe..e80f550bb02e 100644
--- a/comphelper/source/container/containermultiplexer.cxx
+++ b/comphelper/source/container/containermultiplexer.cxx
@@ -29,18 +29,16 @@ namespace comphelper
using namespace ::com::sun::star::container;
OContainerListener::OContainerListener(::osl::Mutex& _rMutex)
- :m_pAdapter(nullptr)
- ,m_rMutex(_rMutex)
+ :m_rMutex(_rMutex)
{
}
OContainerListener::~OContainerListener()
{
- if (m_pAdapter)
+ if (m_xAdapter.is())
{
- m_pAdapter->dispose();
- m_pAdapter = nullptr;
+ m_xAdapter->dispose();
}
}
@@ -71,19 +69,8 @@ namespace comphelper
void OContainerListener::setAdapter(OContainerListenerAdapter* 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;
}
OContainerListenerAdapter::OContainerListenerAdapter(OContainerListener* _pListener,
diff --git a/include/comphelper/containermultiplexer.hxx b/include/comphelper/containermultiplexer.hxx
index 946ff698373d..07b044303dbf 100644
--- a/include/comphelper/containermultiplexer.hxx
+++ b/include/comphelper/containermultiplexer.hxx
@@ -24,6 +24,7 @@
#include <cppuhelper/implbase.hxx>
#include <osl/mutex.hxx>
#include <comphelper/comphelperdllapi.h>
+#include <rtl/ref.hxx>
namespace comphelper
@@ -43,8 +44,8 @@ namespace comphelper
{
friend class OContainerListenerAdapter;
protected:
- OContainerListenerAdapter* m_pAdapter;
- ::osl::Mutex& m_rMutex;
+ rtl::Reference<OContainerListenerAdapter> m_xAdapter;
+ ::osl::Mutex& m_rMutex;
public:
OContainerListener(::osl::Mutex& _rMutex);