Kaydet (Commit) e5404aef authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in svl

Change-Id: I89aa05b3c59ca3ad680d35899400957a399ccf0e
Reviewed-on: https://gerrit.libreoffice.org/47795Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 37464a0f
......@@ -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 );
}
......
......@@ -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 );
......
......@@ -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 );
}
......
......@@ -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:
......
......@@ -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( )
......
......@@ -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();
......
......@@ -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() )
{
......
......@@ -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;
......
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