diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-19 12:35:35 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-19 13:06:47 +0200 |
commit | afb60a273f9ed9f1ff17f25f62ef9dd15a4a7c3a (patch) | |
tree | 564756e77b7d20de74257e62554fdd9c7485f152 /forms | |
parent | 6944b82d6d892e9921af659a4eabec5976511392 (diff) |
use rtl::Reference in OComponentEventThread
instead of storing both a raw pointer and an uno::Reference
Change-Id: I8cd4d04ffb9f40a48d48ade2b171a9a9942cf87f
Diffstat (limited to 'forms')
-rw-r--r-- | forms/source/component/EventThread.cxx | 18 | ||||
-rw-r--r-- | forms/source/component/EventThread.hxx | 8 |
2 files changed, 9 insertions, 17 deletions
diff --git a/forms/source/component/EventThread.cxx b/forms/source/component/EventThread.cxx index e1011b17f26f..f255dbb3868e 100644 --- a/forms/source/component/EventThread.cxx +++ b/forms/source/component/EventThread.cxx @@ -32,17 +32,11 @@ using namespace ::com::sun::star::awt; using namespace ::com::sun::star::lang; OComponentEventThread::OComponentEventThread( ::cppu::OComponentHelper* pCompImpl ) : - m_pCompImpl( pCompImpl ) + m_xComp( pCompImpl ) { osl_atomic_increment(&m_refCount); - // Hold a reference of the Control - { - css::uno::Reference<css::uno::XInterface> xIFace(static_cast<XWeak*>(pCompImpl)); - m_xComp.set(xIFace, css::uno::UNO_QUERY); - } - // and add us at the Control { Reference<XEventListener> xEvtLstnr = static_cast<XEventListener*>(this); @@ -88,7 +82,7 @@ void OComponentEventThread::impl_clearEventQueue() void OComponentEventThread::disposing( const EventObject& evt ) throw ( css::uno::RuntimeException, std::exception) { - if( evt.Source == m_xComp ) + if( evt.Source == static_cast<XWeak*>(m_xComp.get()) ) { ::osl::MutexGuard aGuard( m_aMutex ); @@ -101,8 +95,7 @@ void OComponentEventThread::disposing( const EventObject& evt ) throw ( css::uno // Free the Control and set pCompImpl to 0, // so that the thread knows, that it should terminate. - m_xComp = nullptr; - m_pCompImpl = nullptr; + m_xComp.clear(); // Wake up the thread and terminate m_aCond.set(); @@ -158,8 +151,7 @@ void OComponentEventThread::run() while( m_aEvents.size() > 0 ) { // Get the Control and hold on to it so that it cannot be deleted during actionPerformed - Reference<XComponent> xComp = m_xComp; - ::cppu::OComponentHelper *pCompImpl = m_pCompImpl; + rtl::Reference<::cppu::OComponentHelper> xComp = m_xComp; ThreadEvents::iterator firstEvent( m_aEvents.begin() ); std::unique_ptr<EventObject> pEvt(*firstEvent); @@ -183,7 +175,7 @@ void OComponentEventThread::run() xControlAdapter->queryAdapted(), css::uno::UNO_QUERY); if( xComp.is() ) - processEvent( pCompImpl, pEvt.get(), xControl, bFlag ); + processEvent( xComp.get(), pEvt.get(), xControl, bFlag ); } } diff --git a/forms/source/component/EventThread.hxx b/forms/source/component/EventThread.hxx index e8472f54419c..e83b3bbb9592 100644 --- a/forms/source/component/EventThread.hxx +++ b/forms/source/component/EventThread.hxx @@ -29,11 +29,12 @@ #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/awt/XControl.hpp> #include <osl/thread.hxx> - - #include <osl/conditn.hxx> #include <cppuhelper/component.hxx> #include <comphelper/uno3.hxx> +#include <rtl/ref.hxx> + + using namespace comphelper; @@ -57,8 +58,7 @@ class OComponentEventThread ThreadObjects m_aControls; // Control for Submit ThreadBools m_aFlags; // Flags for Submit/Reset - ::cppu::OComponentHelper* m_pCompImpl; // Implementation of the Control - css::uno::Reference< css::lang::XComponent> m_xComp; // css::lang::XComponent of the Control + rtl::Reference<::cppu::OComponentHelper> m_xComp; // Implementation of the Control protected: |