diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-09-17 13:12:21 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-09-18 14:25:14 +0200 |
commit | 2ae258946eac4f4a9a812de8777e874f1701a61b (patch) | |
tree | fe85d71d4872e0cd9185e2ccb571bf3fb2b0c201 /UnoControls/source/base | |
parent | 3a1aa1c2e7192fa3fa0e3fdca70ef4dd68e215e9 (diff) |
loplugin:useuniqueptr in BaseContainerControl
Change-Id: If78893d47d2b504b01652575579c6972a3863a09
Reviewed-on: https://gerrit.libreoffice.org/60620
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'UnoControls/source/base')
-rw-r--r-- | UnoControls/source/base/basecontainercontrol.cxx | 37 |
1 files changed, 5 insertions, 32 deletions
diff --git a/UnoControls/source/base/basecontainercontrol.cxx b/UnoControls/source/base/basecontainercontrol.cxx index 3896cf7bacee..b5dd4853f7e3 100644 --- a/UnoControls/source/base/basecontainercontrol.cxx +++ b/UnoControls/source/base/basecontainercontrol.cxx @@ -43,7 +43,6 @@ BaseContainerControl::BaseContainerControl( const Reference< XComponentContext > BaseContainerControl::~BaseContainerControl() { - impl_cleanMemory(); } // XInterface @@ -207,7 +206,7 @@ void SAL_CALL BaseContainerControl::addControl ( const OUString& rName, const Re pNewControl->xControl = rControl; // and insert in list - maControlInfoList.push_back( pNewControl ); + maControlInfoList.emplace_back( pNewControl ); // initialize new control pNewControl->xControl->setContext ( static_cast<OWeakObject*>(this) ); @@ -257,7 +256,7 @@ void SAL_CALL BaseContainerControl::removeControl ( const Reference< XControl > for ( size_t n = 0; n < nControls; n++ ) { // Search for right control - IMPL_ControlInfo* pControl = maControlInfoList[ n ]; + IMPL_ControlInfo* pControl = maControlInfoList[ n ].get(); if ( rControl == pControl->xControl ) { //.is it found ... remove listener from control @@ -265,10 +264,7 @@ void SAL_CALL BaseContainerControl::removeControl ( const Reference< XControl > pControl->xControl->setContext ( Reference< XInterface > () ); // ... free memory - delete pControl; - ::std::vector<IMPL_ControlInfo*>::iterator itr = maControlInfoList.begin(); - ::std::advance(itr, n); - maControlInfoList.erase(itr); + maControlInfoList.erase(maControlInfoList.begin() + n); // Send message to all other listener OInterfaceContainerHelper * pInterfaceContainer = m_aListeners.getContainer( cppu::UnoType<XContainerListener>::get()); @@ -319,7 +315,7 @@ Reference< XControl > SAL_CALL BaseContainerControl::getControl ( const OUString // Search for right control for( size_t nCount = 0; nCount < nControls; ++nCount ) { - IMPL_ControlInfo* pSearchControl = maControlInfoList[ nCount ]; + IMPL_ControlInfo* pSearchControl = maControlInfoList[ nCount ].get(); if ( pSearchControl->sName == rName ) { @@ -348,7 +344,7 @@ Sequence< Reference< XControl > > SAL_CALL BaseContainerControl::getControls () // Copy controls to sequence for( nCount = 0; nCount < nControls; ++nCount ) { - IMPL_ControlInfo* pCopyControl = maControlInfoList[ nCount ]; + IMPL_ControlInfo* pCopyControl = maControlInfoList[ nCount ].get(); pDestination [ nCount ] = pCopyControl->xControl; } @@ -414,29 +410,6 @@ void BaseContainerControl::impl_activateTabControllers () } } -// private method - -void BaseContainerControl::impl_cleanMemory () -{ - // Get count of listitems. - size_t nMaxCount = maControlInfoList.size(); - size_t nCount = 0; - - // Delete all items. - for ( nCount = 0; nCount < nMaxCount; ++nCount ) - { - // Delete every time first element of list! - // We count from 0 to MAX, where "MAX=count of items" BEFORE we delete some elements! - // If we use "GetObject ( nCount )" ... it can be, that we have an index greater then count of current elements! - - IMPL_ControlInfo* pSearchControl = maControlInfoList[ nCount ]; - delete pSearchControl; - } - - // Delete list himself. - maControlInfoList.clear (); -} - } // namespace unocontrols /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |