[Libreoffice-commits] core.git: svl/source

Noel Grandin noel.grandin at collabora.co.uk
Sat Jan 13 10:21:00 UTC 2018


 svl/source/fsstor/oinputstreamcontainer.cxx        |    7 +------
 svl/source/fsstor/oinputstreamcontainer.hxx        |    3 ++-
 svl/source/fsstor/ostreamcontainer.cxx             |    7 +------
 svl/source/fsstor/ostreamcontainer.hxx             |    3 ++-
 svl/source/numbers/supservs.cxx                    |   14 ++++----------
 svl/source/numbers/supservs.hxx                    |    3 ++-
 svl/source/passwordcontainer/passwordcontainer.cxx |   14 +++-----------
 svl/source/passwordcontainer/passwordcontainer.hxx |    2 +-
 8 files changed, 16 insertions(+), 37 deletions(-)

New commits:
commit e5404aef868f21ac15e8255892e2171a9377cb47
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Fri Jan 12 08:21:51 2018 +0200

    loplugin:useuniqueptr in svl
    
    Change-Id: I89aa05b3c59ca3ad680d35899400957a399ccf0e
    Reviewed-on: https://gerrit.libreoffice.org/47795
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/svl/source/fsstor/oinputstreamcontainer.cxx b/svl/source/fsstor/oinputstreamcontainer.cxx
index d64c52de01ea..c7ff2e015e1c 100644
--- a/svl/source/fsstor/oinputstreamcontainer.cxx
+++ b/svl/source/fsstor/oinputstreamcontainer.cxx
@@ -36,11 +36,6 @@ OFSInputStreamContainer::OFSInputStreamContainer( const uno::Reference< io::XInp
 
 OFSInputStreamContainer::~OFSInputStreamContainer()
 {
-    if ( m_pListenersContainer )
-    {
-        delete m_pListenersContainer;
-        m_pListenersContainer = nullptr;
-    }
 }
 
 uno::Sequence< uno::Type > SAL_CALL OFSInputStreamContainer::getTypes()
@@ -267,7 +262,7 @@ void SAL_CALL OFSInputStreamContainer::addEventListener( const uno::Reference< l
         throw lang::DisposedException();
 
     if ( !m_pListenersContainer )
-        m_pListenersContainer = new ::comphelper::OInterfaceContainerHelper2( m_aMutex );
+        m_pListenersContainer.reset( new ::comphelper::OInterfaceContainerHelper2( m_aMutex ) );
 
     m_pListenersContainer->addInterface( xListener );
 }
diff --git a/svl/source/fsstor/oinputstreamcontainer.hxx b/svl/source/fsstor/oinputstreamcontainer.hxx
index 130f8120f9fd..9d9a17a79302 100644
--- a/svl/source/fsstor/oinputstreamcontainer.hxx
+++ b/svl/source/fsstor/oinputstreamcontainer.hxx
@@ -29,6 +29,7 @@
 #include <comphelper/interfacecontainer2.hxx>
 
 #include <osl/mutex.hxx>
+#include <memory>
 
 class OFSInputStreamContainer : public cppu::WeakImplHelper < css::io::XInputStream
                                                             ,css::embed::XExtendedStorageStream >
@@ -43,7 +44,7 @@ class OFSInputStreamContainer : public cppu::WeakImplHelper < css::io::XInputStr
 
     bool m_bDisposed;
 
-    ::comphelper::OInterfaceContainerHelper2* m_pListenersContainer; // list of listeners
+    std::unique_ptr<::comphelper::OInterfaceContainerHelper2> m_pListenersContainer; // list of listeners
 
 public:
     explicit OFSInputStreamContainer( const css::uno::Reference < css::io::XInputStream >& xStream );
diff --git a/svl/source/fsstor/ostreamcontainer.cxx b/svl/source/fsstor/ostreamcontainer.cxx
index 8b22d3bec84f..d4c97b0b6f94 100644
--- a/svl/source/fsstor/ostreamcontainer.cxx
+++ b/svl/source/fsstor/ostreamcontainer.cxx
@@ -56,11 +56,6 @@ OFSStreamContainer::OFSStreamContainer( const uno::Reference < io::XStream >& xS
 
 OFSStreamContainer::~OFSStreamContainer()
 {
-    if ( m_pListenersContainer )
-    {
-        delete m_pListenersContainer;
-        m_pListenersContainer = nullptr;
-    }
 }
 
 // XInterface
@@ -259,7 +254,7 @@ void SAL_CALL OFSStreamContainer::addEventListener( const uno::Reference< lang::
         throw lang::DisposedException();
 
     if ( !m_pListenersContainer )
-        m_pListenersContainer = new ::comphelper::OInterfaceContainerHelper2( m_aMutex );
+        m_pListenersContainer.reset(new ::comphelper::OInterfaceContainerHelper2( m_aMutex ));
 
     m_pListenersContainer->addInterface( xListener );
 }
diff --git a/svl/source/fsstor/ostreamcontainer.hxx b/svl/source/fsstor/ostreamcontainer.hxx
index e0668a5bcd5e..a631817d05ba 100644
--- a/svl/source/fsstor/ostreamcontainer.hxx
+++ b/svl/source/fsstor/ostreamcontainer.hxx
@@ -33,6 +33,7 @@
 #include <cppuhelper/typeprovider.hxx>
 #include <comphelper/interfacecontainer2.hxx>
 #include <osl/mutex.hxx>
+#include <memory>
 
 class OFSStreamContainer : public cppu::OWeakObject,
                      public css::lang::XTypeProvider,
@@ -56,7 +57,7 @@ class OFSStreamContainer : public cppu::OWeakObject,
     bool m_bInputClosed;
     bool m_bOutputClosed;
 
-    ::comphelper::OInterfaceContainerHelper2* m_pListenersContainer; // list of listeners
+    std::unique_ptr<::comphelper::OInterfaceContainerHelper2> m_pListenersContainer; // list of listeners
     ::cppu::OTypeCollection* m_pTypeCollection;
 
 public:
diff --git a/svl/source/numbers/supservs.cxx b/svl/source/numbers/supservs.cxx
index c0724ce0cc57..9a287a75c148 100644
--- a/svl/source/numbers/supservs.cxx
+++ b/svl/source/numbers/supservs.cxx
@@ -46,11 +46,6 @@ SvNumberFormatsSupplierServiceObject::SvNumberFormatsSupplierServiceObject(const
 
 SvNumberFormatsSupplierServiceObject::~SvNumberFormatsSupplierServiceObject()
 {
-    if (m_pOwnFormatter)
-    {
-        delete m_pOwnFormatter;
-        m_pOwnFormatter = nullptr;
-    }
 }
 
 Any SAL_CALL SvNumberFormatsSupplierServiceObject::queryAggregation( const Type& _rType )
@@ -76,9 +71,8 @@ void SAL_CALL SvNumberFormatsSupplierServiceObject::initialize( const Sequence<
         // you should use XMultiServiceFactory::createInstanceWithArguments to avoid that
     if (m_pOwnFormatter)
     {   // !!! this is only a emergency handling, normally this should not occur !!!
-        delete m_pOwnFormatter;
-        m_pOwnFormatter = nullptr;
-        SetNumberFormatter(m_pOwnFormatter);
+        m_pOwnFormatter.reset();
+        SetNumberFormatter(m_pOwnFormatter.get());
     }
 
     Type aExpectedArgType = ::cppu::UnoType<css::lang::Locale>::get();
@@ -102,9 +96,9 @@ void SAL_CALL SvNumberFormatsSupplierServiceObject::initialize( const Sequence<
 #endif
     }
 
-    m_pOwnFormatter = new SvNumberFormatter( m_xORB, eNewFormatterLanguage);
+    m_pOwnFormatter.reset( new SvNumberFormatter( m_xORB, eNewFormatterLanguage) );
     m_pOwnFormatter->SetEvalDateFormat( NF_EVALDATEFORMAT_FORMAT_INTL );
-    SetNumberFormatter(m_pOwnFormatter);
+    SetNumberFormatter(m_pOwnFormatter.get());
 }
 
 OUString SAL_CALL SvNumberFormatsSupplierServiceObject::getImplementationName(  )
diff --git a/svl/source/numbers/supservs.hxx b/svl/source/numbers/supservs.hxx
index 919ae9d461da..88676b5e5668 100644
--- a/svl/source/numbers/supservs.hxx
+++ b/svl/source/numbers/supservs.hxx
@@ -24,6 +24,7 @@
 #include <svl/zforlist.hxx>
 #include <com/sun/star/lang/XInitialization.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
+#include <memory>
 
 /**
  * SvNumberFormatsSupplierServiceObject - a number formats supplier which
@@ -37,7 +38,7 @@ class SvNumberFormatsSupplierServiceObject final
             ,public css::lang::XInitialization
             ,public css::lang::XServiceInfo
 {
-    SvNumberFormatter*                                  m_pOwnFormatter;
+    std::unique_ptr<SvNumberFormatter>                  m_pOwnFormatter;
     css::uno::Reference< css::uno::XComponentContext >  m_xORB;
 
     void implEnsureFormatter();
diff --git a/svl/source/passwordcontainer/passwordcontainer.cxx b/svl/source/passwordcontainer/passwordcontainer.cxx
index 6b8401fd5093..4e04fd1071e5 100644
--- a/svl/source/passwordcontainer/passwordcontainer.cxx
+++ b/svl/source/passwordcontainer/passwordcontainer.cxx
@@ -377,7 +377,7 @@ PasswordContainer::PasswordContainer( const Reference<XMultiServiceFactory>& xSe
     mComponent.set( xServiceFactory, UNO_QUERY );
     mComponent->addEventListener( this );
 
-    m_pStorageFile = new StorageItem( this, "Office.Common/Passwords" );
+    m_pStorageFile.reset( new StorageItem( this, "Office.Common/Passwords" ) );
     if( m_pStorageFile->useStorage() )
         m_aContainer = m_pStorageFile->getInfo();
 }
@@ -387,11 +387,7 @@ PasswordContainer::~PasswordContainer()
 {
     ::osl::MutexGuard aGuard( mMutex );
 
-    if( m_pStorageFile )
-    {
-        delete m_pStorageFile;
-        m_pStorageFile = nullptr;
-    }
+    m_pStorageFile.reset();
 
     if( mComponent.is() )
     {
@@ -404,11 +400,7 @@ void SAL_CALL PasswordContainer::disposing( const EventObject& )
 {
     ::osl::MutexGuard aGuard( mMutex );
 
-    if( m_pStorageFile )
-    {
-        delete m_pStorageFile;
-        m_pStorageFile = nullptr;
-    }
+    m_pStorageFile.reset();
 
     if( mComponent.is() )
     {
diff --git a/svl/source/passwordcontainer/passwordcontainer.hxx b/svl/source/passwordcontainer/passwordcontainer.hxx
index 9a65f0fe92d4..fee47518b01d 100644
--- a/svl/source/passwordcontainer/passwordcontainer.hxx
+++ b/svl/source/passwordcontainer/passwordcontainer.hxx
@@ -212,7 +212,7 @@ class PasswordContainer : public ::cppu::WeakImplHelper<
 {
 private:
     PassMap      m_aContainer;
-    StorageItem* m_pStorageFile;
+    std::unique_ptr<StorageItem> m_pStorageFile;
     ::osl::Mutex mMutex;
     OUString m_aMasterPasswd; // master password is set when the string is not empty
     css::uno::Reference< css::lang::XComponent > mComponent;


More information about the Libreoffice-commits mailing list