convert some manual ref-counting in dbaccess

Change-Id: I2df7b6b79bff4a5c7358288518c5518b6a7032bf
Reviewed-on: https://gerrit.libreoffice.org/26051
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
This commit is contained in:
Noel Grandin
2016-06-08 10:43:42 +02:00
committed by Noel Grandin
parent 4599858e21
commit 10aaf33986
8 changed files with 35 additions and 54 deletions

View File

@@ -395,7 +395,6 @@ void SAL_CALL DocumentStorageAccess::disposing( const css::lang::EventObject& So
ODatabaseModelImpl::ODatabaseModelImpl( const Reference< XComponentContext >& _rxContext, ODatabaseContext& _rDBContext )
:m_xModel()
,m_xDataSource()
,m_pStorageAccess( nullptr )
,m_aMutex()
,m_aMutexFacade( m_aMutex )
,m_aContainer(4)
@@ -430,7 +429,6 @@ ODatabaseModelImpl::ODatabaseModelImpl(
)
:m_xModel()
,m_xDataSource()
,m_pStorageAccess( nullptr )
,m_aMutex()
,m_aMutexFacade( m_aMutex )
,m_aContainer(4)
@@ -615,11 +613,10 @@ void ODatabaseModelImpl::reset()
::std::vector< TContentPtr > aEmptyContainers( 4 );
m_aContainer.swap( aEmptyContainers );
if ( m_pStorageAccess )
if ( m_pStorageAccess.is() )
{
m_pStorageAccess->dispose();
m_pStorageAccess->release();
m_pStorageAccess = nullptr;
m_pStorageAccess.clear();
}
}
@@ -723,11 +720,10 @@ void ODatabaseModelImpl::dispose()
DBG_UNHANDLED_EXCEPTION();
}
if ( m_pStorageAccess )
if ( m_pStorageAccess.is() )
{
m_pStorageAccess->dispose();
m_pStorageAccess->release();
m_pStorageAccess = nullptr;
m_pStorageAccess.clear();
}
}
@@ -857,12 +853,11 @@ Reference< XStorage > ODatabaseModelImpl::getOrCreateRootStorage()
DocumentStorageAccess* ODatabaseModelImpl::getDocumentStorageAccess()
{
if ( !m_pStorageAccess )
if ( !m_pStorageAccess.is() )
{
m_pStorageAccess = new DocumentStorageAccess( *this );
m_pStorageAccess->acquire();
}
return m_pStorageAccess;
return m_pStorageAccess.get();
}
void ODatabaseModelImpl::modelIsDisposing( const bool _wasInitialized, ResetModelAccess )

View File

@@ -170,7 +170,7 @@ private:
css::uno::WeakReference< css::frame::XModel > m_xModel;
css::uno::WeakReference< css::sdbc::XDataSource > m_xDataSource;
DocumentStorageAccess* m_pStorageAccess;
rtl::Reference<DocumentStorageAccess> m_pStorageAccess;
::comphelper::SharedMutex m_aMutex;
VosMutexFacade m_aMutexFacade;
::std::vector< TContentPtr > m_aContainer; // one for each ObjectType

View File

@@ -407,12 +407,10 @@ ODocumentDefinition::ODocumentDefinition( const Reference< XInterface >& _rxCont
const TContentPtr& _pImpl, bool _bForm )
:OContentHelper(_xORB,_rxContainer,_pImpl)
,OPropertyStateContainer(OContentHelper::rBHelper)
,m_pInterceptor(nullptr)
,m_bForm(_bForm)
,m_bOpenInDesign(false)
,m_bInExecute(false)
,m_bRemoveListener(false)
,m_pClientHelper(nullptr)
{
registerProperties();
}
@@ -435,11 +433,10 @@ ODocumentDefinition::~ODocumentDefinition()
dispose();
}
if ( m_pInterceptor )
if ( m_pInterceptor.is() )
{
m_pInterceptor->dispose();
m_pInterceptor->release();
m_pInterceptor = nullptr;
m_pInterceptor.clear();
}
}
@@ -458,11 +455,10 @@ void ODocumentDefinition::closeObject()
{
}
m_xEmbeddedObject = nullptr;
if ( m_pClientHelper )
if ( m_pClientHelper.is() )
{
m_pClientHelper->resetClient(nullptr);
m_pClientHelper->release();
m_pClientHelper = nullptr;
m_pClientHelper.clear();
}
}
}
@@ -1492,16 +1488,14 @@ Sequence< PropertyValue > ODocumentDefinition::fillLoadArgs( const Reference< XC
const Sequence< PropertyValue >& i_rOpenCommandArguments, Sequence< PropertyValue >& _out_rEmbeddedObjectDescriptor )
{
// (re-)create interceptor, and put it into the descriptor of the embedded object
if ( m_pInterceptor )
if ( m_pInterceptor.is() )
{
m_pInterceptor->dispose();
m_pInterceptor->release();
m_pInterceptor = nullptr;
m_pInterceptor.clear();
}
m_pInterceptor = new OInterceptor( this );
m_pInterceptor->acquire();
Reference<XDispatchProviderInterceptor> xInterceptor = m_pInterceptor;
Reference<XDispatchProviderInterceptor> xInterceptor = m_pInterceptor.get();
::comphelper::NamedValueCollection aEmbeddedDescriptor;
aEmbeddedDescriptor.put( "OutplaceDispatchInterceptor", xInterceptor );
@@ -1625,12 +1619,11 @@ void ODocumentDefinition::loadEmbeddedObject( const Reference< XConnection >& i_
),UNO_QUERY);
if ( m_xEmbeddedObject.is() )
{
if ( !m_pClientHelper )
if ( !m_pClientHelper.is() )
{
m_pClientHelper = new OEmbeddedClientHelper(this);
m_pClientHelper->acquire();
}
Reference<XEmbeddedClient> xClient = m_pClientHelper;
Reference<XEmbeddedClient> xClient = m_pClientHelper.get();
m_xEmbeddedObject->setClientSite(xClient);
m_xEmbeddedObject->changeState(EmbedStates::RUNNING);
if ( bSetSize )
@@ -1648,12 +1641,11 @@ void ODocumentDefinition::loadEmbeddedObject( const Reference< XConnection >& i_
sal_Int32 nCurrentState = m_xEmbeddedObject->getCurrentState();
if ( nCurrentState == EmbedStates::LOADED )
{
if ( !m_pClientHelper )
if ( !m_pClientHelper.is() )
{
m_pClientHelper = new OEmbeddedClientHelper(this);
m_pClientHelper->acquire();
}
Reference<XEmbeddedClient> xClient = m_pClientHelper;
Reference<XEmbeddedClient> xClient = m_pClientHelper.get();
m_xEmbeddedObject->setClientSite(xClient);
Sequence< PropertyValue > aEmbeddedObjectDescriptor;

View File

@@ -64,12 +64,12 @@ class ODocumentDefinition
css::uno::Reference< css::embed::XStateChangeListener > m_xListener;
css::uno::Reference< css::sdbc::XConnection > m_xLastKnownConnection;
OInterceptor* m_pInterceptor;
rtl::Reference<OInterceptor> m_pInterceptor;
bool m_bForm; // <TRUE/> if it is a form
bool m_bOpenInDesign;
bool m_bInExecute;
bool m_bRemoveListener;
OEmbeddedClientHelper* m_pClientHelper;
rtl::Reference<OEmbeddedClientHelper> m_pClientHelper;
protected:
virtual ~ODocumentDefinition();

View File

@@ -276,7 +276,6 @@ OApplicationController::OApplicationController(const Reference< XComponentContex
,m_pSubComponentManager( new SubComponentManager( *this, getSharedMutex() ) )
,m_aTypeCollection( _rxORB )
,m_aTableCopyHelper(this)
,m_pClipbordNotifier(nullptr)
,m_nAsyncDrop(nullptr)
,m_aSelectContainerEvent( LINK( this, OApplicationController, OnSelectContainer ) )
,m_ePreviewMode(E_PREVIEWNONE)
@@ -341,10 +340,9 @@ void SAL_CALL OApplicationController::disposing()
if ( getView() )
{
getContainer()->showPreview(nullptr);
m_pClipbordNotifier->ClearCallbackLink();
m_pClipbordNotifier->RemoveListener( getView() );
m_pClipbordNotifier->release();
m_pClipbordNotifier = nullptr;
m_pClipboardNotifier->ClearCallbackLink();
m_pClipboardNotifier->RemoveListener( getView() );
m_pClipboardNotifier.clear();
}
disconnect();
@@ -446,9 +444,8 @@ bool OApplicationController::Construct(vcl::Window* _pParent)
m_aSystemClipboard = TransferableDataHelper::CreateFromSystemClipboard( getView() );
m_aSystemClipboard.StartClipboardListening( );
m_pClipbordNotifier = new TransferableClipboardListener( LINK( this, OApplicationController, OnClipboardChanged ) );
m_pClipbordNotifier->acquire();
m_pClipbordNotifier->AddListener( getView() );
m_pClipboardNotifier = new TransferableClipboardListener( LINK( this, OApplicationController, OnClipboardChanged ) );
m_pClipboardNotifier->AddListener( getView() );
OGenericUnoController::Construct( _pParent );
getView()->Show();

View File

@@ -109,8 +109,8 @@ namespace dbaui
::dbaccess::ODsnTypeCollection
m_aTypeCollection;
OTableCopyHelper m_aTableCopyHelper;
TransferableClipboardListener*
m_pClipbordNotifier; // notifier for changes in the clipboard
rtl::Reference<TransferableClipboardListener>
m_pClipboardNotifier; // notifier for changes in the clipboard
ImplSVEvent * m_nAsyncDrop;
OAsynchronousLink m_aSelectContainerEvent;
PreviewMode m_ePreviewMode; // the mode of the preview

View File

@@ -533,7 +533,6 @@ Any SAL_CALL SbaXDataBrowserController::queryInterface(const Type& _rType) throw
SbaXDataBrowserController::SbaXDataBrowserController(const Reference< css::uno::XComponentContext >& _rM)
:SbaXDataBrowserController_Base(_rM)
,m_nRowSetPrivileges(0)
,m_pClipbordNotifier( nullptr )
,m_aAsyncGetCellFocus(LINK(this, SbaXDataBrowserController, OnAsyncGetCellFocus))
,m_aAsyncDisplayError( LINK( this, SbaXDataBrowserController, OnAsyncDisplayError ) )
,m_sStateSaveRecord(ModuleRes(RID_STR_SAVE_CURRENT_RECORD))
@@ -784,9 +783,8 @@ bool SbaXDataBrowserController::Construct(vcl::Window* pParent)
m_aSystemClipboard = TransferableDataHelper::CreateFromSystemClipboard( getView() );
m_aSystemClipboard.StartClipboardListening( );
m_pClipbordNotifier = new TransferableClipboardListener( LINK( this, SbaXDataBrowserController, OnClipboardChanged ) );
m_pClipbordNotifier->acquire();
m_pClipbordNotifier->AddListener( getView() );
m_pClipboardNotifier = new TransferableClipboardListener( LINK( this, SbaXDataBrowserController, OnClipboardChanged ) );
m_pClipboardNotifier->AddListener( getView() );
// this call create the toolbox
SbaXDataBrowserController_Base::Construct(pParent);
@@ -1194,12 +1192,11 @@ void SbaXDataBrowserController::disposing()
removeModelListeners(getControlModel());
if ( getView() && m_pClipbordNotifier )
if ( getView() && m_pClipboardNotifier.is() )
{
m_pClipbordNotifier->ClearCallbackLink();
m_pClipbordNotifier->RemoveListener( getView() );
m_pClipbordNotifier->release();
m_pClipbordNotifier = nullptr;
m_pClipboardNotifier->ClearCallbackLink();
m_pClipboardNotifier->RemoveListener( getView() );
m_pClipboardNotifier.clear();
}
if (getBrowserView())

View File

@@ -93,8 +93,8 @@ namespace dbaui
AutoTimer m_aInvalidateClipboard; // for testing the state of the CUT/COPY/PASTE-slots
TransferableDataHelper m_aSystemClipboard; // content of the clipboard
TransferableClipboardListener*
m_pClipbordNotifier; // notifier for changes in the clipboard
rtl::Reference<TransferableClipboardListener>
m_pClipboardNotifier; // notifier for changes in the clipboard
OAsynchronousLink m_aAsyncGetCellFocus;
OAsynchronousLink m_aAsyncDisplayError;