diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-05-31 15:40:25 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-06-12 08:43:48 +0200 |
commit | e4e4d5713e248f02faf7aa6199b11e152973de8e (patch) | |
tree | 836dffa89d0a966e41b1af8270db74b9590def22 /sc/source | |
parent | d4eabd5da8ea3b5ac40659c22cde19b26b3c002b (diff) |
clang-tidy readability-delete-null-pointer
which in turn triggered some loplugin:useuniqueptr
Change-Id: I0c38561fc9b68dac44e8cf58c8aa1f582196cc64
Reviewed-on: https://gerrit.libreoffice.org/38281
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/core/data/dptabsrc.cxx | 24 | ||||
-rw-r--r-- | sc/source/core/tool/chgtrack.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/Accessibility/AccessibleDocument.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/Accessibility/AccessibleText.cxx | 21 | ||||
-rw-r--r-- | sc/source/ui/docshell/tablink.cxx | 2 |
5 files changed, 14 insertions, 38 deletions
diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx index 3537b46863ea..38c21bd0e92b 100644 --- a/sc/source/core/data/dptabsrc.cxx +++ b/sc/source/core/data/dptabsrc.cxx @@ -1198,11 +1198,6 @@ ScDPDimensions::ScDPDimensions( ScDPSource* pSrc ) : ScDPDimensions::~ScDPDimensions() { //TODO: release pSource - - if (ppDims) - { - delete[] ppDims; - } } void ScDPDimensions::CountChanged() @@ -1220,8 +1215,7 @@ void ScDPDimensions::CountChanged() for (i=nCopy; i<nNewCount; i++) // clear additional pointers ppNew[i] = nullptr; - delete[] ppDims; - ppDims = ppNew; + ppDims.reset( ppNew ); } nDimCount = nNewCount; } @@ -1288,7 +1282,7 @@ ScDPDimension* ScDPDimensions::getByIndex(long nIndex) const { if ( !ppDims ) { - const_cast<ScDPDimensions*>(this)->ppDims = new rtl::Reference<ScDPDimension>[nDimCount]; + const_cast<ScDPDimensions*>(this)->ppDims.reset(new rtl::Reference<ScDPDimension>[nDimCount] ); for (long i=0; i<nDimCount; i++) ppDims[i] = nullptr; } @@ -1656,11 +1650,6 @@ ScDPHierarchies::ScDPHierarchies( ScDPSource* pSrc, long nD ) : ScDPHierarchies::~ScDPHierarchies() { //TODO: release pSource - - if (ppHiers) - { - delete[] ppHiers; - } } // very simple XNameAccess implementation using getCount/getByIndex @@ -1725,7 +1714,7 @@ ScDPHierarchy* ScDPHierarchies::getByIndex(long nIndex) const { if ( !ppHiers ) { - const_cast<ScDPHierarchies*>(this)->ppHiers = new rtl::Reference<ScDPHierarchy>[nHierCount]; + const_cast<ScDPHierarchies*>(this)->ppHiers.reset( new rtl::Reference<ScDPHierarchy>[nHierCount] ); for (long i=0; i<nHierCount; i++) ppHiers[i] = nullptr; } @@ -1823,11 +1812,6 @@ ScDPLevels::ScDPLevels( ScDPSource* pSrc, long nD, long nH ) : ScDPLevels::~ScDPLevels() { //TODO: release pSource - - if (ppLevs) - { - delete[] ppLevs; - } } // very simple XNameAccess implementation using getCount/getByIndex @@ -1889,7 +1873,7 @@ ScDPLevel* ScDPLevels::getByIndex(long nIndex) const { if ( !ppLevs ) { - const_cast<ScDPLevels*>(this)->ppLevs = new rtl::Reference<ScDPLevel>[nLevCount]; + const_cast<ScDPLevels*>(this)->ppLevs.reset(new rtl::Reference<ScDPLevel>[nLevCount] ); for (long i=0; i<nLevCount; i++) ppLevs[i] = nullptr; } diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx index d46891ff0095..cb9421ea5996 100644 --- a/sc/source/core/tool/chgtrack.cxx +++ b/sc/source/core/tool/chgtrack.cxx @@ -4389,7 +4389,7 @@ bool ScChangeTrack::Reject( pReject->SetState( SC_CAS_ACCEPTED ); Append( pReject ); } - else if ( pReject ) + else delete pReject; } else diff --git a/sc/source/ui/Accessibility/AccessibleDocument.cxx b/sc/source/ui/Accessibility/AccessibleDocument.cxx index b367101ea151..fd501a44030b 100644 --- a/sc/source/ui/Accessibility/AccessibleDocument.cxx +++ b/sc/source/ui/Accessibility/AccessibleDocument.cxx @@ -1204,8 +1204,7 @@ void ScChildrenShapes::SetAnchor(const uno::Reference<drawing::XShape>& xShape, if ((pAddress && pData->pRelationCell && (*pAddress != *(pData->pRelationCell))) || (!pAddress && pData->pRelationCell) || (pAddress && !pData->pRelationCell)) { - if (pData->pRelationCell) - delete pData->pRelationCell; + delete pData->pRelationCell; pData->pRelationCell = pAddress; if (pData->pAccShape.is()) pData->pAccShape->SetRelationSet(GetRelationSet(pData)); diff --git a/sc/source/ui/Accessibility/AccessibleText.cxx b/sc/source/ui/Accessibility/AccessibleText.cxx index 5b6f8df55add..7e80fd96571a 100644 --- a/sc/source/ui/Accessibility/AccessibleText.cxx +++ b/sc/source/ui/Accessibility/AccessibleText.cxx @@ -672,10 +672,8 @@ ScAccessibleCellTextData::~ScAccessibleCellTextData() { if (pEditEngine) pEditEngine->SetNotifyHdl(Link<EENotify&,void>()); - if (mpViewForwarder) - delete mpViewForwarder; - if (mpEditViewForwarder) - delete mpEditViewForwarder; + delete mpViewForwarder; + delete mpEditViewForwarder; } void ScAccessibleCellTextData::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) @@ -897,12 +895,9 @@ ScAccessibleEditObjectTextData::~ScAccessibleEditObjectTextData() // If the object is cloned, do NOT set notify hdl. if (mpEditEngine && !mbIsCloned) mpEditEngine->SetNotifyHdl(Link<EENotify&,void>()); - if (mpViewForwarder) - delete mpViewForwarder; - if (mpEditViewForwarder) - delete mpEditViewForwarder; - if (mpForwarder) - delete mpForwarder; + delete mpViewForwarder; + delete mpEditViewForwarder; + delete mpForwarder; } void ScAccessibleEditObjectTextData::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) @@ -1159,8 +1154,7 @@ ScAccessiblePreviewCellTextData::~ScAccessiblePreviewCellTextData() { if (pEditEngine) pEditEngine->SetNotifyHdl(Link<EENotify&,void>()); - if (mpViewForwarder) - delete mpViewForwarder; + delete mpViewForwarder; } void ScAccessiblePreviewCellTextData::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) @@ -1232,8 +1226,7 @@ ScAccessiblePreviewHeaderCellTextData::~ScAccessiblePreviewHeaderCellTextData() { if (pEditEngine) pEditEngine->SetNotifyHdl(Link<EENotify&,void>()); - if (mpViewForwarder) - delete mpViewForwarder; + delete mpViewForwarder; } void ScAccessiblePreviewHeaderCellTextData::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) diff --git a/sc/source/ui/docshell/tablink.cxx b/sc/source/ui/docshell/tablink.cxx index 11fdce37cf2d..b3b00683960e 100644 --- a/sc/source/ui/docshell/tablink.cxx +++ b/sc/source/ui/docshell/tablink.cxx @@ -538,7 +538,7 @@ ScDocumentLoader::~ScDocumentLoader() { if ( aRef.is() ) aRef->DoClose(); - else if ( pMedium ) + else delete pMedium; } |