summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-03-16 14:38:30 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-03-16 19:24:29 +0100
commit92dc87cbac74c1be260534b5e38088c44515a47b (patch)
tree2ecd20074d908a16bce720439ce5c327cdc5789b /sd
parent8015e0a15d1b8c454c26c645c7e8ebee9c4e1ee1 (diff)
loplugin:useuniqueptr in SvUnoWeakContainer
just use a std::vector here, these are small objects, no need to allocate them separately Change-Id: Ie9f8df88eb7c291e2c99177d0f5e4bfc1c7ab542 Reviewed-on: https://gerrit.libreoffice.org/51415 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd')
-rw-r--r--sd/source/ui/unoidl/unowcntr.cxx24
-rw-r--r--sd/source/ui/unoidl/unowcntr.hxx2
2 files changed, 10 insertions, 16 deletions
diff --git a/sd/source/ui/unoidl/unowcntr.cxx b/sd/source/ui/unoidl/unowcntr.cxx
index bb1687b07362..7583b1f569d4 100644
--- a/sd/source/ui/unoidl/unowcntr.cxx
+++ b/sd/source/ui/unoidl/unowcntr.cxx
@@ -29,9 +29,6 @@ SvUnoWeakContainer::SvUnoWeakContainer() throw()
SvUnoWeakContainer::~SvUnoWeakContainer() throw()
{
- for (auto const& elem : maVector)
- delete elem;
- maVector.clear();
}
/** inserts the given ref into this container */
@@ -39,21 +36,20 @@ void SvUnoWeakContainer::insert( const uno::WeakReference< uno::XInterface >& xR
{
for ( auto it = maVector.begin(); it != maVector.end(); )
{
- uno::WeakReference< uno::XInterface >* pRef = *it;
- uno::Reference< uno::XInterface > xTestRef( *pRef );
+ uno::WeakReference< uno::XInterface > & rWeakRef = *it;
+ uno::Reference< uno::XInterface > xTestRef( rWeakRef );
if ( !xTestRef.is() )
{
- delete pRef;
it = maVector.erase( it );
}
else
{
- if ( *pRef == xRef )
+ if ( rWeakRef == xRef )
return;
++it;
}
}
- maVector.push_back( new uno::WeakReference< uno::XInterface >( xRef ) );
+ maVector.emplace_back( uno::WeakReference< uno::XInterface >( xRef ) );
}
/** searches the container for a ref that returns true on the given
@@ -67,18 +63,17 @@ bool SvUnoWeakContainer::findRef(
{
for ( auto it = maVector.begin(); it != maVector.end(); )
{
- uno::WeakReference< uno::XInterface >* pRef = *it;
- uno::Reference< uno::XInterface > xTestRef( *pRef );
+ uno::WeakReference< uno::XInterface > & itRef = *it;
+ uno::Reference< uno::XInterface > xTestRef( itRef );
if ( !xTestRef.is() )
{
- delete pRef;
it = maVector.erase( it );
}
else
{
- if( (*pSearchFunc)( *pRef, pSearchData ) )
+ if( (*pSearchFunc)( itRef, pSearchData ) )
{
- rRef = *pRef;
+ rRef = itRef;
return true;
}
++it;
@@ -91,8 +86,7 @@ void SvUnoWeakContainer::dispose()
{
for (auto const& elem : maVector)
{
- uno::WeakReference< uno::XInterface >* pRef = elem;
- uno::Reference< uno::XInterface > xTestRef( *pRef );
+ uno::Reference< uno::XInterface > xTestRef( elem );
if ( xTestRef.is() )
{
uno::Reference< lang::XComponent > xComp( xTestRef, uno::UNO_QUERY );
diff --git a/sd/source/ui/unoidl/unowcntr.hxx b/sd/source/ui/unoidl/unowcntr.hxx
index 787c81d3c3b3..8d1a5e441912 100644
--- a/sd/source/ui/unoidl/unowcntr.hxx
+++ b/sd/source/ui/unoidl/unowcntr.hxx
@@ -28,7 +28,7 @@ typedef bool (*weakref_searchfunc)( const css::uno::WeakReference< css::uno::XIn
class SvUnoWeakContainer
{
private:
- std::vector< css::uno::WeakReference< css::uno::XInterface >* > maVector;
+ std::vector< css::uno::WeakReference< css::uno::XInterface > > maVector;
public:
SvUnoWeakContainer() throw();