diff options
-rw-r--r-- | comphelper/source/misc/SelectionMultiplex.cxx | 15 | ||||
-rw-r--r-- | include/comphelper/SelectionMultiplex.hxx | 7 |
2 files changed, 6 insertions, 16 deletions
diff --git a/comphelper/source/misc/SelectionMultiplex.cxx b/comphelper/source/misc/SelectionMultiplex.cxx index f7122d40b946..15c2c9476b6e 100644 --- a/comphelper/source/misc/SelectionMultiplex.cxx +++ b/comphelper/source/misc/SelectionMultiplex.cxx @@ -44,19 +44,8 @@ void OSelectionChangeListener::_disposing(const EventObject&) void OSelectionChangeListener::setAdapter(OSelectionChangeMultiplexer* 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; } OSelectionChangeMultiplexer::OSelectionChangeMultiplexer(OSelectionChangeListener* _pListener, const Reference< XSelectionSupplier>& _rxSet) diff --git a/include/comphelper/SelectionMultiplex.hxx b/include/comphelper/SelectionMultiplex.hxx index c63cd8fa046a..552ce3bf76a4 100644 --- a/include/comphelper/SelectionMultiplex.hxx +++ b/include/comphelper/SelectionMultiplex.hxx @@ -24,6 +24,7 @@ #include <com/sun/star/view/XSelectionSupplier.hpp> #include <cppuhelper/implbase.hxx> #include <comphelper/comphelperdllapi.h> +#include <rtl/ref.hxx> //= selection helper classes @@ -43,12 +44,12 @@ namespace comphelper { friend class OSelectionChangeMultiplexer; - OSelectionChangeMultiplexer* m_pAdapter; - ::osl::Mutex& m_rMutex; + rtl::Reference<OSelectionChangeMultiplexer> m_xAdapter; + ::osl::Mutex& m_rMutex; public: OSelectionChangeListener(::osl::Mutex& _rMutex) - : m_pAdapter(nullptr), m_rMutex(_rMutex) { } + : m_rMutex(_rMutex) { } virtual ~OSelectionChangeListener(); /// @throws css::uno::RuntimeException |