use rtl::Reference in OComponentEventThread
instead of storing both a raw pointer and an uno::Reference Change-Id: I8cd4d04ffb9f40a48d48ade2b171a9a9942cf87f
This commit is contained in:
@@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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:
|
||||
|
||||
|
Reference in New Issue
Block a user