Kaydet (Commit) f3fc127d authored tarafından Mike Kaganski's avatar Mike Kaganski

Use osl_atomic_increment/osl_atomic_decrement to change m_refCount

Change-Id: Ia24441d3671102fdeeb797547396c25ee2a6ffd3
Reviewed-on: https://gerrit.libreoffice.org/70382
Tested-by: Jenkins
Reviewed-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst 817e3447
......@@ -48,7 +48,7 @@ ProgressMonitor::ProgressMonitor( const css::uno::Reference< XComponentContext >
{
// It's not allowed to work with member in this method (refcounter !!!)
// But with a HACK (++refcount) its "OK" :-(
++m_refCount;
osl_atomic_increment(&m_refCount);
// Create instances for fixedtext, button and progress ...
......@@ -94,7 +94,7 @@ ProgressMonitor::ProgressMonitor( const css::uno::Reference< XComponentContext >
m_xTopic_Bottom->setText ( PROGRESSMONITOR_DEFAULT_TOPIC );
m_xText_Bottom->setText ( PROGRESSMONITOR_DEFAULT_TEXT );
--m_refCount;
osl_atomic_decrement(&m_refCount);
}
ProgressMonitor::~ProgressMonitor()
......
......@@ -42,7 +42,7 @@ StatusIndicator::StatusIndicator( const css::uno::Reference< XComponentContext >
{
// It's not allowed to work with member in this method (refcounter !!!)
// But with a HACK (++refcount) its "OK" :-(
++m_refCount;
osl_atomic_increment(&m_refCount);
// Create instances for fixedtext and progress ...
m_xText.set( rxContext->getServiceManager()->createInstanceWithContext( FIXEDTEXT_SERVICENAME, rxContext ), UNO_QUERY );
......@@ -61,7 +61,7 @@ StatusIndicator::StatusIndicator( const css::uno::Reference< XComponentContext >
// (progressbar take automatically its own defaults)
m_xText->setText( "" );
--m_refCount;
osl_atomic_decrement(&m_refCount);
}
StatusIndicator::~StatusIndicator() {}
......
......@@ -105,14 +105,14 @@ void OEnumerationByName::impl_startDisposeListening()
if (m_bListening)
return;
++m_refCount;
osl_atomic_increment(&m_refCount);
css::uno::Reference< css::lang::XComponent > xDisposable(m_xAccess, css::uno::UNO_QUERY);
if (xDisposable.is())
{
xDisposable->addEventListener(this);
m_bListening = true;
}
--m_refCount;
osl_atomic_decrement(&m_refCount);
}
......@@ -123,14 +123,14 @@ void OEnumerationByName::impl_stopDisposeListening()
if (!m_bListening)
return;
++m_refCount;
osl_atomic_increment(&m_refCount);
css::uno::Reference< css::lang::XComponent > xDisposable(m_xAccess, css::uno::UNO_QUERY);
if (xDisposable.is())
{
xDisposable->removeEventListener(this);
m_bListening = false;
}
--m_refCount;
osl_atomic_decrement(&m_refCount);
}
OEnumerationByIndex::OEnumerationByIndex(const css::uno::Reference< css::container::XIndexAccess >& _rxAccess)
......@@ -201,14 +201,14 @@ void OEnumerationByIndex::impl_startDisposeListening()
if (m_bListening)
return;
++m_refCount;
osl_atomic_increment(&m_refCount);
css::uno::Reference< css::lang::XComponent > xDisposable(m_xAccess, css::uno::UNO_QUERY);
if (xDisposable.is())
{
xDisposable->addEventListener(this);
m_bListening = true;
}
--m_refCount;
osl_atomic_decrement(&m_refCount);
}
......@@ -219,14 +219,14 @@ void OEnumerationByIndex::impl_stopDisposeListening()
if (!m_bListening)
return;
++m_refCount;
osl_atomic_increment(&m_refCount);
css::uno::Reference< css::lang::XComponent > xDisposable(m_xAccess, css::uno::UNO_QUERY);
if (xDisposable.is())
{
xDisposable->removeEventListener(this);
m_bListening = false;
}
--m_refCount;
osl_atomic_decrement(&m_refCount);
}
OAnyEnumeration::OAnyEnumeration(const css::uno::Sequence< css::uno::Any >& lItems)
......
......@@ -50,7 +50,7 @@ OInstanceLocker::~OInstanceLocker()
{
if ( !m_bDisposed )
{
m_refCount++; // to call dispose
osl_atomic_increment(&m_refCount); // to call dispose
try {
dispose();
}
......
......@@ -261,7 +261,7 @@ OCommonEmbeddedObject::~OCommonEmbeddedObject()
{
if ( m_pInterfaceContainer || m_xDocHolder.is() )
{
m_refCount++;
osl_atomic_increment(&m_refCount);
try {
lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >( this ) );
......
......@@ -173,7 +173,7 @@ DocumentHolder::DocumentHolder( const uno::Reference< uno::XComponentContext >&
m_aOutplaceFrameProps[1] <<= aArg;
uno::Reference< frame::XDesktop2 > xDesktop = frame::Desktop::create( m_xContext );
m_refCount++;
osl_atomic_increment(&m_refCount);
try
{
xDesktop->addTerminateListener( this );
......@@ -181,7 +181,7 @@ DocumentHolder::DocumentHolder( const uno::Reference< uno::XComponentContext >&
catch ( const uno::Exception& )
{
}
m_refCount--;
osl_atomic_decrement(&m_refCount);
aArg.Name = "ParentFrame";
aArg.Value <<= xDesktop; //TODO/LATER: should use parent document frame
......@@ -191,7 +191,7 @@ DocumentHolder::DocumentHolder( const uno::Reference< uno::XComponentContext >&
DocumentHolder::~DocumentHolder()
{
m_refCount++; // to allow deregistration as a listener
osl_atomic_increment(&m_refCount); // to allow deregistration as a listener
if( m_xFrame.is() )
CloseFrame();
......
......@@ -142,7 +142,7 @@ OleEmbeddedObject::~OleEmbeddedObject()
if ( m_pOleComponent || m_pInterfaceContainer || m_xObjectStream.is() )
{
// the component must be cleaned during closing
m_refCount++; // to avoid crash
osl_atomic_increment(&m_refCount); // to avoid crash
try {
Dispose();
} catch( const uno::Exception& ) {}
......
......@@ -67,7 +67,7 @@ OInputCompStream::~OInputCompStream()
if ( !m_bDisposed )
{
m_refCount++;
osl_atomic_increment(&m_refCount);
dispose();
}
}
......
......@@ -1668,7 +1668,7 @@ OWriteStream::~OWriteStream()
::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
if ( m_pImpl )
{
m_refCount++;
osl_atomic_increment(&m_refCount);
try {
dispose();
}
......
......@@ -1793,7 +1793,7 @@ OStorage::~OStorage()
::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
if ( m_pImpl )
{
m_refCount++; // to call dispose
osl_atomic_increment(&m_refCount); // to call dispose
try {
dispose();
}
......
......@@ -61,7 +61,8 @@ OZipFileAccess::~OZipFileAccess()
if ( !m_bDisposed )
{
try {
m_refCount++; // dispose will use refcounting so the further destruction must be avoided
// dispose will use refcounting so the further destruction must be avoided
osl_atomic_increment(&m_refCount);
dispose();
} catch( uno::Exception& )
{}
......
......@@ -1409,12 +1409,12 @@ ScCellRangesBase::ScCellRangesBase(ScDocShell* pDocSh, const ScRange& rR) :
{
// this is a hack to get m_wThis initialized; ideally there would be
// factory functions doing this but there are so many subclasses of this...
++m_refCount;
osl_atomic_increment(&m_refCount);
{
m_wThis = uno::Reference<uno::XInterface>(
static_cast<cppu::OWeakObject*>(this));
}
--m_refCount;
osl_atomic_decrement(&m_refCount);
ScRange aCellRange(rR);
aCellRange.PutInOrder();
......@@ -1441,12 +1441,12 @@ ScCellRangesBase::ScCellRangesBase(ScDocShell* pDocSh, const ScRangeList& rR) :
{
// this is a hack to get m_wThis initialized; ideally there would be
// factory functions doing this but there are so many subclasses of this...
++m_refCount;
osl_atomic_increment(&m_refCount);
{
m_wThis = uno::Reference<uno::XInterface>(
static_cast<cppu::OWeakObject*>(this));
}
--m_refCount;
osl_atomic_decrement(&m_refCount);
if (pDocShell) // Null if created with createInstance
{
......
......@@ -143,10 +143,10 @@ SfxGlobalEvents_Impl::SfxGlobalEvents_Impl( const uno::Reference < uno::XCompone
, m_aLegacyListeners (m_aLock)
, m_aDocumentListeners (m_aLock)
{
m_refCount++;
osl_atomic_increment(&m_refCount);
SfxApplication::GetOrCreate();
m_xEvents = new GlobalEventConfig();
m_refCount--;
osl_atomic_decrement(&m_refCount);
}
uno::Reference< container::XNameReplace > SAL_CALL SfxGlobalEvents_Impl::getEvents()
......
......@@ -181,12 +181,12 @@ public:
, pWorkWindow( pWork )
, _nStartTime(0)
{
++m_refCount;
osl_atomic_increment(&m_refCount);
Reference< lang::XComponent > xComponent(
static_cast< ::cppu::OWeakObject* >(pController), uno::UNO_QUERY );
if (xComponent.is())
xComponent->addEventListener(this);
--m_refCount;
osl_atomic_decrement(&m_refCount);
}
virtual void SAL_CALL start(const OUString& aText, sal_Int32 nRange) override;
......
......@@ -140,7 +140,7 @@ OLESimpleStorage::OLESimpleStorage(
OLESimpleStorage::~OLESimpleStorage()
{
try {
m_refCount++;
osl_atomic_increment(&m_refCount);
dispose();
} catch( uno::Exception& )
{}
......
......@@ -102,7 +102,7 @@ FSStorage::FSStorage( const ::ucbhelper::Content& aContent,
FSStorage::~FSStorage()
{
::osl::MutexGuard aGuard( m_aMutex );
m_refCount++; // to call dispose
osl_atomic_increment(&m_refCount); // to call dispose
try {
dispose();
}
......
......@@ -904,10 +904,10 @@ SwXShape::SwXShape(uno::Reference<uno::XInterface> & xShape,
}
}
xShape = nullptr;
m_refCount++;
osl_atomic_increment(&m_refCount);
if( xShapeAgg.is() )
xShapeAgg->setDelegator( static_cast<cppu::OWeakObject*>(this) );
m_refCount--;
osl_atomic_decrement(&m_refCount);
uno::Reference< lang::XUnoTunnel > xShapeTunnel(xShapeAgg, uno::UNO_QUERY);
SvxShape* pShape = nullptr;
......
......@@ -83,13 +83,13 @@ SwDBTreeList_Impl::~SwDBTreeList_Impl()
{
if(m_xDatabaseContext.is())
{
m_refCount++;
osl_atomic_increment(&m_refCount);
//block necessary due to solaris' compiler behaviour to
//remove temporaries at the block's end
{
m_xDatabaseContext->removeContainerListener( this );
}
m_refCount--;
osl_atomic_decrement(&m_refCount);
}
}
......
......@@ -224,7 +224,7 @@ void SwView_Impl::Invalidate()
void SwView_Impl::AddTransferable(SwTransferable& rTransferable)
{
//prevent removing of the non-referenced SwTransferable
rTransferable.m_refCount++;
osl_atomic_increment(&rTransferable.m_refCount);
{
// Remove previously added, but no longer existing weak references.
mxTransferables.erase(std::remove_if(mxTransferables.begin(), mxTransferables.end(),
......@@ -235,7 +235,7 @@ void SwView_Impl::AddTransferable(SwTransferable& rTransferable)
mxTransferables.emplace_back(uno::Reference<lang::XUnoTunnel>(&rTransferable));
}
rTransferable.m_refCount--;
osl_atomic_decrement(&rTransferable.m_refCount);
}
void SwView_Impl::StartDocumentInserter(
......
......@@ -46,14 +46,14 @@ SwXDispatchProviderInterceptor::SwXDispatchProviderInterceptor(SwView& rVw) :
m_xIntercepted.set(xUnoFrame, uno::UNO_QUERY);
if(m_xIntercepted.is())
{
m_refCount++;
osl_atomic_increment(&m_refCount);
m_xIntercepted->registerDispatchProviderInterceptor(static_cast<frame::XDispatchProviderInterceptor*>(this));
// this should make us the top-level dispatch-provider for the component, via a call to our
// setDispatchProvider we should have got an fallback for requests we (i.e. our master) cannot fulfill
uno::Reference< lang::XComponent> xInterceptedComponent(m_xIntercepted, uno::UNO_QUERY);
if (xInterceptedComponent.is())
xInterceptedComponent->addEventListener(static_cast<lang::XEventListener*>(this));
m_refCount--;
osl_atomic_decrement(&m_refCount);
}
}
......
......@@ -120,7 +120,7 @@ void SwXTextView::Invalidate()
mxTextViewCursor.clear();
}
m_refCount++; //prevent second d'tor call
osl_atomic_increment(&m_refCount); //prevent second d'tor call
{
uno::Reference<uno::XInterface> const xInt(static_cast<
......@@ -129,7 +129,7 @@ void SwXTextView::Invalidate()
m_SelChangedListeners.disposeAndClear(aEvent);
}
m_refCount--;
osl_atomic_decrement(&m_refCount);
m_pView = nullptr;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment