void OProxyAggregation::baseAggregateProxyFor( const Reference< XInterface >& _rxComponent, oslInterlockedCount& _rRefCount,
::cppu::OWeakObject& _rDelegator )
{ // first a factory for the proxy
Reference< XProxyFactory > xFactory = ProxyFactory::create( m_xContext );
// then the proxy itself
{ // i36686 OJ: achieve the destruction of the temporary -> otherwise it leads to _rRefCount -= 2
m_xProxyAggregate = xFactory->createProxy( _rxComponent );
} if ( m_xProxyAggregate.is() )
m_xProxyAggregate->queryAggregation( cppu::UnoType<decltype(m_xProxyTypeAccess)>::get() ) >>= m_xProxyTypeAccess;
// aggregate the proxy
osl_atomic_increment( &_rRefCount ); if ( m_xProxyAggregate.is() )
{ // At this point in time, the proxy has a ref count of exactly two - in m_xControlContextProxy, // and in m_xProxyTypeAccess. // Remember to _not_ reset these members unless the delegator of the proxy has been reset, too!
m_xProxyAggregate->setDelegator( _rDelegator );
}
osl_atomic_decrement( &_rRefCount );
}
Sequence< Type > SAL_CALL OProxyAggregation::getTypes( )
{
Sequence< Type > aTypes; if ( m_xProxyAggregate.is() )
{ if ( m_xProxyTypeAccess.is() )
aTypes = m_xProxyTypeAccess->getTypes();
} return aTypes;
}
OProxyAggregation::~OProxyAggregation()
{ if ( m_xProxyAggregate.is() )
m_xProxyAggregate->setDelegator( nullptr );
m_xProxyAggregate.clear();
m_xProxyTypeAccess.clear(); // this should remove the _two_only_ "real" references (means not delegated to // ourself) to this proxy, and thus delete it
}
// aggregate a proxy for the object
baseAggregateProxyFor( m_xInner, _rRefCount, _rDelegator );
// add as event listener to the inner context, because we want to be notified of disposals
osl_atomic_increment( &_rRefCount );
{ if ( m_xInner.is() )
m_xInner->addEventListener( this );
}
osl_atomic_decrement( &_rRefCount );
}
Any SAL_CALL OComponentProxyAggregationHelper::queryInterface( const Type& _rType )
{
Any aReturn( BASE::queryInterface( _rType ) ); if ( !aReturn.hasValue() )
aReturn = OProxyAggregation::queryAggregation( _rType ); return aReturn;
}
OComponentProxyAggregationHelper::~OComponentProxyAggregationHelper( )
{
OSL_ENSURE( m_rBHelper.bDisposed, "OComponentProxyAggregationHelper::~OComponentProxyAggregationHelper: you should dispose your derived class in the dtor, if necessary!" ); // if this asserts, add the following to your derived class dtor:
// if ( !m_rBHelper.bDisposed ) // { // acquire(); // to prevent duplicate dtor calls // dispose(); // }
m_xInner.clear();
}
void SAL_CALL OComponentProxyAggregationHelper::disposing( const EventObject& _rSource )
{ if ( _rSource.Source == m_xInner )
{ // it's our inner context which is dying -> dispose ourself if ( !m_rBHelper.bDisposed && !m_rBHelper.bInDispose )
{ // (if necessary only, of course)
dispose();
}
}
}
// dispose our inner context // before we do this, remove ourself as listener - else in disposing( EventObject ), we // would dispose ourself a second time if ( m_xInner.is() )
{
m_xInner->removeEventListener( this );
m_xInner->dispose();
m_xInner.clear();
}
}
Sequence< Type > SAL_CALL OComponentProxyAggregation::getTypes( )
{ return comphelper::concatSequences(
OComponentProxyAggregationHelper::getTypes(), // append XComponent, coming from WeakComponentImplHelperBase
std::initializer_list<Type>{ cppu::UnoType<XComponent>::get() });
}
void SAL_CALL OComponentProxyAggregation::disposing( const EventObject& _rSource )
{ // Simply disambiguate---this is necessary for MSVC to distinguish // "disposing(EventObject)" from "disposing()"; but it is also a good // place to check for recursive calls that would be caused by an object // being registered as an XEventListener at itself (cf. rhbz#928568):
assert(_rSource.Source != static_cast< cppu::OWeakObject * >(this));
OComponentProxyAggregationHelper::disposing( _rSource );
}
void SAL_CALL OComponentProxyAggregation::disposing()
{ // call the dispose-functionality of the base, which will dispose our aggregated component
OComponentProxyAggregationHelper::dispose();
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.