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

loplugin:useuniqueptr in ModelData_Impl

Change-Id: I66866ed1698fafe59ba31f99df09fb792da410e3
Reviewed-on: https://gerrit.libreoffice.org/48702Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 5da6e7d2
...@@ -235,6 +235,9 @@ void UseUniquePtr::CheckForForLoopDelete(const CXXDestructorDecl* destructorDecl ...@@ -235,6 +235,9 @@ void UseUniquePtr::CheckForForLoopDelete(const CXXDestructorDecl* destructorDecl
StringRef aFileName = compiler.getSourceManager().getFilename(compiler.getSourceManager().getSpellingLoc(fieldDecl->getLocStart())); StringRef aFileName = compiler.getSourceManager().getFilename(compiler.getSourceManager().getSpellingLoc(fieldDecl->getLocStart()));
if (loplugin::hasPathnamePrefix(aFileName, WORKDIR)) if (loplugin::hasPathnamePrefix(aFileName, WORKDIR))
continue; continue;
// the std::vector is being passed to another class
if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/sfx2/source/explorer/nochaos.cxx"))
return;
report( report(
DiagnosticsEngine::Warning, DiagnosticsEngine::Warning,
......
...@@ -275,8 +275,8 @@ class ModelData_Impl ...@@ -275,8 +275,8 @@ class ModelData_Impl
uno::Reference< frame::XStorable2 > m_xStorable2; uno::Reference< frame::XStorable2 > m_xStorable2;
OUString m_aModuleName; OUString m_aModuleName;
::comphelper::SequenceAsHashMap* m_pDocumentPropsHM; std::unique_ptr<::comphelper::SequenceAsHashMap> m_pDocumentPropsHM;
::comphelper::SequenceAsHashMap* m_pModulePropsHM; std::unique_ptr<::comphelper::SequenceAsHashMap> m_pModulePropsHM;
::comphelper::SequenceAsHashMap m_aMediaDescrHM; ::comphelper::SequenceAsHashMap m_aMediaDescrHM;
...@@ -381,18 +381,14 @@ ModelData_Impl::ModelData_Impl( SfxStoringHelper& aOwner, ...@@ -381,18 +381,14 @@ ModelData_Impl::ModelData_Impl( SfxStoringHelper& aOwner,
ModelData_Impl::~ModelData_Impl() ModelData_Impl::~ModelData_Impl()
{ {
FreeDocumentProps(); FreeDocumentProps();
delete m_pDocumentPropsHM; m_pDocumentPropsHM.reset();
delete m_pModulePropsHM; m_pModulePropsHM.reset();
} }
void ModelData_Impl::FreeDocumentProps() void ModelData_Impl::FreeDocumentProps()
{ {
if ( m_pDocumentPropsHM ) m_pDocumentPropsHM.reset();
{
delete m_pDocumentPropsHM;
m_pDocumentPropsHM = nullptr;
}
} }
...@@ -430,7 +426,7 @@ uno::Reference< frame::XStorable2 > const & ModelData_Impl::GetStorable2() ...@@ -430,7 +426,7 @@ uno::Reference< frame::XStorable2 > const & ModelData_Impl::GetStorable2()
const ::comphelper::SequenceAsHashMap& ModelData_Impl::GetDocProps() const ::comphelper::SequenceAsHashMap& ModelData_Impl::GetDocProps()
{ {
if ( !m_pDocumentPropsHM ) if ( !m_pDocumentPropsHM )
m_pDocumentPropsHM = new ::comphelper::SequenceAsHashMap( GetModel()->getArgs() ); m_pDocumentPropsHM.reset( new ::comphelper::SequenceAsHashMap( GetModel()->getArgs() ) );
return *m_pDocumentPropsHM; return *m_pDocumentPropsHM;
} }
...@@ -457,7 +453,7 @@ const ::comphelper::SequenceAsHashMap& ModelData_Impl::GetModuleProps() ...@@ -457,7 +453,7 @@ const ::comphelper::SequenceAsHashMap& ModelData_Impl::GetModuleProps()
m_pOwner->GetModuleManager()->getByName( GetModuleName() ) >>= aModuleProps; m_pOwner->GetModuleManager()->getByName( GetModuleName() ) >>= aModuleProps;
if ( !aModuleProps.getLength() ) if ( !aModuleProps.getLength() )
throw uno::RuntimeException(); // TODO; throw uno::RuntimeException(); // TODO;
m_pModulePropsHM = new ::comphelper::SequenceAsHashMap( aModuleProps ); m_pModulePropsHM.reset( new ::comphelper::SequenceAsHashMap( aModuleProps ) );
} }
return *m_pModulePropsHM; return *m_pModulePropsHM;
......
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