From e4e4d5713e248f02faf7aa6199b11e152973de8e Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 31 May 2017 15:40:25 +0200 Subject: 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 Reviewed-by: Noel Grandin --- cui/source/customize/cfg.cxx | 13 ++++------ cui/source/inc/cfg.hxx | 2 +- .../source/primitive3d/sdrextrudeprimitive3d.cxx | 7 +----- .../source/primitive3d/sdrlatheprimitive3d.cxx | 7 +----- .../source/processor3d/zbufferprocessor3d.cxx | 5 +--- editeng/source/rtf/svxrtf.cxx | 3 +-- filter/source/graphicfilter/ios2met/ios2met.cxx | 6 ++--- filter/source/graphicfilter/itiff/ccidecom.cxx | 3 +-- hwpfilter/source/htags.cxx | 3 +-- .../primitive3d/sdrextrudeprimitive3d.hxx | 3 ++- .../primitive3d/sdrlatheprimitive3d.hxx | 3 ++- include/vcl/metaact.hxx | 5 ++-- io/source/acceptor/acceptor.cxx | 10 ++------ io/source/stm/omark.cxx | 15 +++--------- .../source/filter/lwpcharborderoverride.cxx | 10 ++------ lotuswordpro/source/filter/lwpdlvlist.cxx | 6 +---- lotuswordpro/source/filter/lwpdlvlist.hxx | 5 ++-- lotuswordpro/source/filter/lwpdoc.cxx | 10 ++------ lotuswordpro/source/filter/lwpfont.cxx | 4 +--- lotuswordpro/source/filter/lwpfont.hxx | 3 ++- lotuswordpro/source/filter/lwpgrfobj.cxx | 8 ++----- lotuswordpro/source/filter/lwpoverride.cxx | 28 ++++------------------ lotuswordpro/source/filter/lwpoverride.hxx | 3 ++- lotuswordpro/source/filter/lwppara.cxx | 5 +--- lotuswordpro/source/filter/lwptablelayout.cxx | 6 +---- lotuswordpro/source/filter/lwptablelayout.hxx | 6 +++-- registry/source/reflwrit.cxx | 6 ++--- sc/inc/dptabsrc.hxx | 9 ++++--- sc/source/core/data/dptabsrc.cxx | 24 ++++--------------- sc/source/core/tool/chgtrack.cxx | 2 +- sc/source/ui/Accessibility/AccessibleDocument.cxx | 3 +-- sc/source/ui/Accessibility/AccessibleText.cxx | 21 ++++++---------- sc/source/ui/docshell/tablink.cxx | 2 +- .../source/provider/BrowseNodeFactoryImpl.cxx | 15 ++++-------- scripting/source/provider/MasterScriptProvider.cxx | 11 +++------ scripting/source/provider/MasterScriptProvider.hxx | 3 ++- sd/source/filter/eppt/pptx-grouptable.cxx | 3 +-- sd/source/ui/sidebar/MasterPagesSelector.cxx | 3 +-- sd/source/ui/view/OutlinerIterator.cxx | 3 +-- sd/source/ui/view/drviewsc.cxx | 5 +--- sd/source/ui/view/viewshel.cxx | 3 +-- sfx2/source/control/request.cxx | 3 +-- sfx2/source/doc/docfile.cxx | 3 +-- svgio/source/svgreader/svgnode.cxx | 17 +++---------- svx/inc/sdr/contact/viewobjectcontactofgraphic.hxx | 3 ++- .../sdr/contact/viewobjectcontactofgraphic.cxx | 13 +++------- svx/source/sdr/properties/textproperties.cxx | 5 +--- svx/source/svdraw/svdedxv.cxx | 5 +--- svx/source/svdraw/svdopath.cxx | 23 ++++++------------ svx/source/svdraw/svdpagv.cxx | 6 +---- svx/source/svdraw/textchainflow.cxx | 6 ++--- svx/source/xoutdev/xpool.cxx | 5 +--- sw/source/core/doc/docsort.cxx | 4 +--- sw/source/core/text/wrong.cxx | 6 ++--- sw/source/core/undo/unins.cxx | 2 +- sw/source/filter/ww8/ww8par5.cxx | 5 +--- vcl/inc/unx/salobj.h | 6 +++-- vcl/source/gdi/metaact.cxx | 28 ++++++++++------------ vcl/source/opengl/OpenGLHelper.cxx | 3 +-- vcl/source/window/accel.cxx | 4 +--- vcl/unx/generic/window/salframe.cxx | 3 +-- vcl/unx/generic/window/salobj.cxx | 17 +++++-------- xmlscript/source/xml_helper/xml_impctx.cxx | 20 ++++------------ 63 files changed, 145 insertions(+), 334 deletions(-) diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx index b70d6c57faf4..fdd046357b67 100644 --- a/cui/source/customize/cfg.cxx +++ b/cui/source/customize/cfg.cxx @@ -935,10 +935,6 @@ MenuSaveInData::MenuSaveInData( MenuSaveInData::~MenuSaveInData() { - if ( pRootEntry != nullptr ) - { - delete pRootEntry; - } } SvxEntries* @@ -946,16 +942,16 @@ MenuSaveInData::GetEntries() { if ( pRootEntry == nullptr ) { - pRootEntry = new SvxConfigEntry( "MainMenus", OUString(), true); + pRootEntry.reset( new SvxConfigEntry( "MainMenus", OUString(), true) ); if ( m_xMenuSettings.is() ) { - LoadSubMenus( m_xMenuSettings, OUString(), pRootEntry, false ); + LoadSubMenus( m_xMenuSettings, OUString(), pRootEntry.get(), false ); } else if ( GetDefaultData() != nullptr ) { // If the doc has no config settings use module config settings - LoadSubMenus( GetDefaultData()->m_xMenuSettings, OUString(), pRootEntry, false ); + LoadSubMenus( GetDefaultData()->m_xMenuSettings, OUString(), pRootEntry.get(), false ); } } @@ -1226,8 +1222,7 @@ MenuSaveInData::Reset() PersistChanges( GetConfigManager() ); - delete pRootEntry; - pRootEntry = nullptr; + pRootEntry.reset(); try { diff --git a/cui/source/inc/cfg.hxx b/cui/source/inc/cfg.hxx index 329b69526522..0436f15888ec 100644 --- a/cui/source/inc/cfg.hxx +++ b/cui/source/inc/cfg.hxx @@ -168,7 +168,7 @@ private: css::uno::Reference < css::container::XIndexAccess > m_xMenuSettings; - SvxConfigEntry* pRootEntry; + std::unique_ptr pRootEntry; static MenuSaveInData* pDefaultData; ///< static holder of the default menu data diff --git a/drawinglayer/source/primitive3d/sdrextrudeprimitive3d.cxx b/drawinglayer/source/primitive3d/sdrextrudeprimitive3d.cxx index 750d4d8977e3..3f901f61069a 100644 --- a/drawinglayer/source/primitive3d/sdrextrudeprimitive3d.cxx +++ b/drawinglayer/source/primitive3d/sdrextrudeprimitive3d.cxx @@ -442,10 +442,6 @@ namespace drawinglayer SdrExtrudePrimitive3D::~SdrExtrudePrimitive3D() { - if(mpLastRLGViewInformation) - { - delete mpLastRLGViewInformation; - } } bool SdrExtrudePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const @@ -493,8 +489,7 @@ namespace drawinglayer // new one and clear current decompositiopn SdrExtrudePrimitive3D* pThat = const_cast< SdrExtrudePrimitive3D* >(this); pThat->setBuffered3DDecomposition(Primitive3DContainer()); - delete pThat->mpLastRLGViewInformation; - pThat->mpLastRLGViewInformation = new geometry::ViewInformation3D(rViewInformation); + pThat->mpLastRLGViewInformation.reset( new geometry::ViewInformation3D(rViewInformation) ); } } diff --git a/drawinglayer/source/primitive3d/sdrlatheprimitive3d.cxx b/drawinglayer/source/primitive3d/sdrlatheprimitive3d.cxx index 0bffc5801b01..4f38141846ac 100644 --- a/drawinglayer/source/primitive3d/sdrlatheprimitive3d.cxx +++ b/drawinglayer/source/primitive3d/sdrlatheprimitive3d.cxx @@ -302,10 +302,6 @@ namespace drawinglayer SdrLathePrimitive3D::~SdrLathePrimitive3D() { - if(mpLastRLGViewInformation) - { - delete mpLastRLGViewInformation; - } } bool SdrLathePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const @@ -355,8 +351,7 @@ namespace drawinglayer // new one and clear current decompositiopn SdrLathePrimitive3D* pThat = const_cast< SdrLathePrimitive3D* >(this); pThat->setBuffered3DDecomposition(Primitive3DContainer()); - delete pThat->mpLastRLGViewInformation; - pThat->mpLastRLGViewInformation = new geometry::ViewInformation3D(rViewInformation); + pThat->mpLastRLGViewInformation.reset( new geometry::ViewInformation3D(rViewInformation) ); } } diff --git a/drawinglayer/source/processor3d/zbufferprocessor3d.cxx b/drawinglayer/source/processor3d/zbufferprocessor3d.cxx index 8b95d90659b2..1ce54a3bfe36 100644 --- a/drawinglayer/source/processor3d/zbufferprocessor3d.cxx +++ b/drawinglayer/source/processor3d/zbufferprocessor3d.cxx @@ -618,10 +618,7 @@ namespace drawinglayer ZBufferProcessor3D::~ZBufferProcessor3D() { - if(mpZBufferRasterConverter3D) - { - delete mpZBufferRasterConverter3D; - } + delete mpZBufferRasterConverter3D; if(mpRasterPrimitive3Ds) { diff --git a/editeng/source/rtf/svxrtf.cxx b/editeng/source/rtf/svxrtf.cxx index 3eb72a55e656..f1ea65fd69cc 100644 --- a/editeng/source/rtf/svxrtf.cxx +++ b/editeng/source/rtf/svxrtf.cxx @@ -1138,8 +1138,7 @@ SvxRTFItemStackType::SvxRTFItemStackType( SvxRTFItemStackType::~SvxRTFItemStackType() { - if (m_pChildList) - delete m_pChildList; + delete m_pChildList; if( pSttNd != pEndNd ) delete pEndNd; delete pSttNd; diff --git a/filter/source/graphicfilter/ios2met/ios2met.cxx b/filter/source/graphicfilter/ios2met/ios2met.cxx index 5f5b54dba8b3..052ab9b877fc 100644 --- a/filter/source/graphicfilter/ios2met/ios2met.cxx +++ b/filter/source/graphicfilter/ios2met/ios2met.cxx @@ -487,7 +487,7 @@ OS2METReader::~OS2METReader() while (pBitmapList!=nullptr) { OSBitmap * p=pBitmapList; pBitmapList=p->pSucc; - if (p->pBMP!=nullptr) delete p->pBMP; + delete p->pBMP; delete p; } @@ -500,7 +500,7 @@ OS2METReader::~OS2METReader() while (pPaletteStack!=nullptr) { OSPalette * p=pPaletteStack; pPaletteStack=p->pSucc; - if (p->p0RGB!=nullptr) delete[] p->p0RGB; + delete[] p->p0RGB; delete p; } } @@ -2504,7 +2504,7 @@ void OS2METReader::ReadField(sal_uInt16 nFieldType, sal_uInt16 nFieldSize) OSPalette * pP=pPaletteStack; if (pP!=nullptr) { pPaletteStack=pP->pSucc; - if (pP->p0RGB!=nullptr) delete[] pP->p0RGB; + delete[] pP->p0RGB; delete pP; } break; diff --git a/filter/source/graphicfilter/itiff/ccidecom.cxx b/filter/source/graphicfilter/itiff/ccidecom.cxx index a30d5eb98cc1..c57813e98046 100644 --- a/filter/source/graphicfilter/itiff/ccidecom.cxx +++ b/filter/source/graphicfilter/itiff/ccidecom.cxx @@ -672,8 +672,7 @@ DecompressStatus CCIDecompressor::DecompressScanline( sal_uInt8 * pTarget, sal_u { if ( pLastLine == nullptr || nLastLineSize != ( ( nTargetBits + 7 ) >> 3 ) ) { - if ( pLastLine == nullptr ) - delete[] pLastLine; + delete[] pLastLine; nLastLineSize = ( nTargetBits + 7 ) >> 3; pLastLine = new sal_uInt8[ nLastLineSize ]; memset(pLastLine, 0, nLastLineSize); diff --git a/hwpfilter/source/htags.cxx b/hwpfilter/source/htags.cxx index 52e6a78b85f1..3f212b4e9b32 100644 --- a/hwpfilter/source/htags.cxx +++ b/hwpfilter/source/htags.cxx @@ -57,8 +57,7 @@ EmPicture::EmPicture(size_t tsize) #endif EmPicture::~EmPicture() { - if (data) - delete[]data; + delete[] data; }; bool EmPicture::Read(HWPFile & hwpf) diff --git a/include/drawinglayer/primitive3d/sdrextrudeprimitive3d.hxx b/include/drawinglayer/primitive3d/sdrextrudeprimitive3d.hxx index 42bfd7348437..eea2f2f932b4 100644 --- a/include/drawinglayer/primitive3d/sdrextrudeprimitive3d.hxx +++ b/include/drawinglayer/primitive3d/sdrextrudeprimitive3d.hxx @@ -24,6 +24,7 @@ #include #include +#include namespace drawinglayer @@ -55,7 +56,7 @@ namespace drawinglayer double mfBackScale; /// decomposition data when ReducedLineGeometry is used, see get3DDecomposition - geometry::ViewInformation3D* mpLastRLGViewInformation; + std::unique_ptr mpLastRLGViewInformation; bool mbSmoothNormals : 1; // Plane self bool mbSmoothLids : 1; // Front/back diff --git a/include/drawinglayer/primitive3d/sdrlatheprimitive3d.hxx b/include/drawinglayer/primitive3d/sdrlatheprimitive3d.hxx index a26aea5a5cd9..da713c1663fb 100644 --- a/include/drawinglayer/primitive3d/sdrlatheprimitive3d.hxx +++ b/include/drawinglayer/primitive3d/sdrlatheprimitive3d.hxx @@ -24,6 +24,7 @@ #include #include +#include namespace drawinglayer @@ -57,7 +58,7 @@ namespace drawinglayer double mfRotation; /// decomposition data when ReducedLineGeometry is used, see get3DDecomposition - geometry::ViewInformation3D* mpLastRLGViewInformation; + std::unique_ptr mpLastRLGViewInformation; bool mbSmoothNormals : 1; // Plane self bool mbSmoothLids : 1; // Front/back diff --git a/include/vcl/metaact.hxx b/include/vcl/metaact.hxx index 8fe4f1d43845..a5e939e4fd72 100644 --- a/include/vcl/metaact.hxx +++ b/include/vcl/metaact.hxx @@ -1433,7 +1433,8 @@ private: OString maComment; sal_Int32 mnValue; sal_uInt32 mnDataSize; - sal_uInt8* mpData; + std::unique_ptr + mpData; SAL_DLLPRIVATE void ImplInitDynamicData( const sal_uInt8* pData, sal_uInt32 nDataSize ); @@ -1456,7 +1457,7 @@ public: const OString& GetComment() const { return maComment; } sal_Int32 GetValue() const { return mnValue; } sal_uInt32 GetDataSize() const { return mnDataSize; } - const sal_uInt8* GetData() const { return mpData; } + const sal_uInt8* GetData() const { return mpData.get(); } }; class VCL_DLLPUBLIC MetaLayoutModeAction : public MetaAction diff --git a/io/source/acceptor/acceptor.cxx b/io/source/acceptor/acceptor.cxx index cb5deba52546..7dc047a13fb3 100644 --- a/io/source/acceptor/acceptor.cxx +++ b/io/source/acceptor/acceptor.cxx @@ -87,14 +87,8 @@ namespace io_acceptor OAcceptor::~OAcceptor() { - if( m_pPipe ) - { - delete m_pPipe; - } - if( m_pSocket ) - { - delete m_pSocket; - } + delete m_pPipe; + delete m_pSocket; } struct BeingInAccept diff --git a/io/source/stm/omark.cxx b/io/source/stm/omark.cxx index 9053ada96698..cdf1b0924183 100644 --- a/io/source/stm/omark.cxx +++ b/io/source/stm/omark.cxx @@ -410,7 +410,6 @@ class OMarkableInputStream : { public: OMarkableInputStream( ); - virtual ~OMarkableInputStream() override; public: // XInputStream @@ -452,7 +451,7 @@ private: Reference< XInputStream > m_input; bool m_bValidStream; - MemRingBuffer *m_pBuffer; + std::unique_ptr m_pBuffer; map > m_mapMarks; sal_Int32 m_nCurrentPos; sal_Int32 m_nCurrentMark; @@ -465,14 +464,7 @@ OMarkableInputStream::OMarkableInputStream() , m_nCurrentPos(0) , m_nCurrentMark(0) { - m_pBuffer = new MemRingBuffer; -} - -OMarkableInputStream::~OMarkableInputStream() -{ - if( m_pBuffer ) { - delete m_pBuffer; - } + m_pBuffer.reset( new MemRingBuffer ); } @@ -615,8 +607,7 @@ void OMarkableInputStream::closeInput() setPredecessor( Reference< XConnectable > () ); setSuccessor( Reference< XConnectable >() ); - delete m_pBuffer; - m_pBuffer = nullptr; + m_pBuffer.reset(); m_nCurrentPos = 0; m_nCurrentMark = 0; } diff --git a/lotuswordpro/source/filter/lwpcharborderoverride.cxx b/lotuswordpro/source/filter/lwpcharborderoverride.cxx index d7cb9bc281cd..e8dabf5c0d64 100644 --- a/lotuswordpro/source/filter/lwpcharborderoverride.cxx +++ b/lotuswordpro/source/filter/lwpcharborderoverride.cxx @@ -88,14 +88,8 @@ LwpCharacterBorderOverride::LwpCharacterBorderOverride(LwpCharacterBorderOverrid LwpCharacterBorderOverride::~LwpCharacterBorderOverride() { - if (m_pBorderStuff) - { - delete m_pBorderStuff; - } - if (m_pMargins) - { - delete m_pMargins; - } + delete m_pBorderStuff; + delete m_pMargins; } LwpCharacterBorderOverride* LwpCharacterBorderOverride::clone() const diff --git a/lotuswordpro/source/filter/lwpdlvlist.cxx b/lotuswordpro/source/filter/lwpdlvlist.cxx index 22781f15eb8b..2e2ea5886d1c 100644 --- a/lotuswordpro/source/filter/lwpdlvlist.cxx +++ b/lotuswordpro/source/filter/lwpdlvlist.cxx @@ -142,7 +142,7 @@ void LwpDLNFPVList::ReadPropertyList(LwpObjectStream* pObjStrm) m_bHasProperties = pObjStrm->QuickReaduInt8() != 0; if (m_bHasProperties) { - m_pPropList = new LwpPropList; + m_pPropList.reset( new LwpPropList ); m_pPropList->Read(pObjStrm); } } @@ -152,10 +152,6 @@ void LwpDLNFPVList::ReadPropertyList(LwpObjectStream* pObjStrm) **/ LwpDLNFPVList::~LwpDLNFPVList() { - if(m_pPropList) - { - delete m_pPropList; - } } /** diff --git a/lotuswordpro/source/filter/lwpdlvlist.hxx b/lotuswordpro/source/filter/lwpdlvlist.hxx index bf9063c0b150..54a5b5d24030 100644 --- a/lotuswordpro/source/filter/lwpdlvlist.hxx +++ b/lotuswordpro/source/filter/lwpdlvlist.hxx @@ -63,6 +63,7 @@ #include "lwpatomholder.hxx" #include "lwpobj.hxx" +#include /** * @brief Double Linked Virtual List @@ -119,12 +120,12 @@ public: virtual ~LwpDLNFPVList() override; protected: bool m_bHasProperties; - LwpPropList* m_pPropList; + std::unique_ptr m_pPropList; protected: void Read() override; void ReadPropertyList(LwpObjectStream* pObjStrm); public: - LwpPropList* GetPropList() { return m_pPropList; } + LwpPropList* GetPropList() { return m_pPropList.get(); } }; /** diff --git a/lotuswordpro/source/filter/lwpdoc.cxx b/lotuswordpro/source/filter/lwpdoc.cxx index 65eb22784ec7..9455c6b91854 100644 --- a/lotuswordpro/source/filter/lwpdoc.cxx +++ b/lotuswordpro/source/filter/lwpdoc.cxx @@ -81,14 +81,8 @@ LwpDocument::LwpDocument(LwpObjectHeader& objHdr, LwpSvStream* pStrm) LwpDocument::~LwpDocument() { - if(m_pLnOpts) - { - delete m_pLnOpts; - } - if(m_pOwnedFoundry) - { - delete m_pOwnedFoundry; - } + delete m_pLnOpts; + delete m_pOwnedFoundry; } /** * @descr Read VO_Document from object stream diff --git a/lotuswordpro/source/filter/lwpfont.cxx b/lotuswordpro/source/filter/lwpfont.cxx index 98772071362a..8b430866a3b8 100644 --- a/lotuswordpro/source/filter/lwpfont.cxx +++ b/lotuswordpro/source/filter/lwpfont.cxx @@ -415,7 +415,7 @@ OUString LwpFontNameManager::GetNameByIndex(sal_uInt16 index) void LwpFontAttrManager::Read(LwpObjectStream *pStrm) { m_nCount = pStrm->QuickReaduInt16(); - m_pFontAttrs = new LwpFontAttrEntry[m_nCount]; + m_pFontAttrs.reset( new LwpFontAttrEntry[m_nCount] ); for(sal_uInt16 i=0; i co LwpFontAttrManager::~LwpFontAttrManager() { - if(m_pFontAttrs) - delete []m_pFontAttrs; } void LwpFontManager::Read(LwpObjectStream *pStrm) diff --git a/lotuswordpro/source/filter/lwpfont.hxx b/lotuswordpro/source/filter/lwpfont.hxx index b0297fbbade7..1f6987fdea3a 100644 --- a/lotuswordpro/source/filter/lwpfont.hxx +++ b/lotuswordpro/source/filter/lwpfont.hxx @@ -72,6 +72,7 @@ #include "lwpobj.hxx" #include "xfilter/xffont.hxx" #include "xfilter/xftextstyle.hxx" +#include class LwpFontTableEntry { @@ -253,7 +254,7 @@ public: void Override(sal_uInt16 index, rtl::Reference const & pFont); private: sal_uInt16 m_nCount; - LwpFontAttrEntry* m_pFontAttrs; + std::unique_ptr m_pFontAttrs; }; class LwpFontManager diff --git a/lotuswordpro/source/filter/lwpgrfobj.cxx b/lotuswordpro/source/filter/lwpgrfobj.cxx index 64f855ce9ce0..19df22f7481b 100644 --- a/lotuswordpro/source/filter/lwpgrfobj.cxx +++ b/lotuswordpro/source/filter/lwpgrfobj.cxx @@ -199,12 +199,8 @@ void LwpGraphicObject::Read() m_WatermarkName = m_pObjStrm->QuickReadStringPtr(); } - if (pServerContext != nullptr) - delete[] pServerContext; - - if (pFilterContext != nullptr) - delete[] pFilterContext; - + delete[] pServerContext; + delete[] pFilterContext; } void LwpGraphicObject::XFConvert (XFContentContainer* pCont) diff --git a/lotuswordpro/source/filter/lwpoverride.cxx b/lotuswordpro/source/filter/lwpoverride.cxx index 5856a4c8db42..f943bf728155 100644 --- a/lotuswordpro/source/filter/lwpoverride.cxx +++ b/lotuswordpro/source/filter/lwpoverride.cxx @@ -359,22 +359,10 @@ m_pParaSpacingBelow(new LwpSpacingCommonOverride) LwpSpacingOverride::~LwpSpacingOverride() { - if (m_pSpacing) - { - delete m_pSpacing; - } - if (m_pAboveLineSpacing) - { - delete m_pAboveLineSpacing; - } - if (m_pParaSpacingAbove) - { - delete m_pParaSpacingAbove; - } - if (m_pParaSpacingBelow) - { - delete m_pParaSpacingBelow; - } + delete m_pSpacing; + delete m_pAboveLineSpacing; + delete m_pParaSpacingAbove; + delete m_pParaSpacingBelow; } LwpSpacingOverride::LwpSpacingOverride(LwpSpacingOverride const& rOther) @@ -454,19 +442,13 @@ m_pBackgroundStuff(new LwpBackgroundStuff), m_nType(AMIKAKE_NONE) LwpAmikakeOverride::~LwpAmikakeOverride() { - if (m_pBackgroundStuff) - { - delete m_pBackgroundStuff; - } } LwpAmikakeOverride::LwpAmikakeOverride(LwpAmikakeOverride const& rOther) : LwpOverride(rOther) - , m_pBackgroundStuff(nullptr) + , m_pBackgroundStuff(::clone(rOther.m_pBackgroundStuff.get())) , m_nType(rOther.m_nType) { - std::unique_ptr pBackgroundStuff(::clone(rOther.m_pBackgroundStuff)); - m_pBackgroundStuff = pBackgroundStuff.release(); } LwpAmikakeOverride* LwpAmikakeOverride::clone() const diff --git a/lotuswordpro/source/filter/lwpoverride.hxx b/lotuswordpro/source/filter/lwpoverride.hxx index c88ed65ea937..935fd0f7bbbe 100644 --- a/lotuswordpro/source/filter/lwpoverride.hxx +++ b/lotuswordpro/source/filter/lwpoverride.hxx @@ -63,6 +63,7 @@ #include "lwpobjid.hxx" #include "lwptools.hxx" +#include class LwpObjectStream; @@ -493,7 +494,7 @@ private: LwpAmikakeOverride& operator=(LwpAmikakeOverride const& rOther) = delete; private: - LwpBackgroundStuff* m_pBackgroundStuff; + std::unique_ptr m_pBackgroundStuff; sal_uInt16 m_nType; }; diff --git a/lotuswordpro/source/filter/lwppara.cxx b/lotuswordpro/source/filter/lwppara.cxx index 10acd0ab88a3..eabeb993cb57 100644 --- a/lotuswordpro/source/filter/lwppara.cxx +++ b/lotuswordpro/source/filter/lwppara.cxx @@ -134,10 +134,7 @@ LwpPara::~LwpPara() delete m_pBullOver; m_pBullOver = nullptr; } - if(m_pIndentOverride) - { - delete m_pIndentOverride; - } + delete m_pIndentOverride; LwpParaProperty* pNextProp; while(m_pProps) diff --git a/lotuswordpro/source/filter/lwptablelayout.cxx b/lotuswordpro/source/filter/lwptablelayout.cxx index f25104985339..5b63e64cac59 100644 --- a/lotuswordpro/source/filter/lwptablelayout.cxx +++ b/lotuswordpro/source/filter/lwptablelayout.cxx @@ -87,15 +87,11 @@ LwpSuperTableLayout::LwpSuperTableLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm) : LwpPlacableLayout(objHdr, pStrm) { - m_pFrame = new LwpFrame(this); + m_pFrame.reset(new LwpFrame(this) ); } LwpSuperTableLayout::~LwpSuperTableLayout() { - if(m_pFrame) - { - delete m_pFrame; - } } /** * @short Read super table layout record diff --git a/lotuswordpro/source/filter/lwptablelayout.hxx b/lotuswordpro/source/filter/lwptablelayout.hxx index 11ffd63b2938..7237df9591fc 100644 --- a/lotuswordpro/source/filter/lwptablelayout.hxx +++ b/lotuswordpro/source/filter/lwptablelayout.hxx @@ -61,9 +61,11 @@ #ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPTABLELAYOUT_HXX #define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPTABLELAYOUT_HXX +#include "lwplayout.hxx" + #include #include -#include "lwplayout.hxx" +#include class XFTableStyle; class XFTable; @@ -181,7 +183,7 @@ protected: LwpTableLayout* GetTableLayout(); bool IsSizeRightToContent(); bool IsJustifiable(); - LwpFrame* m_pFrame; + std::unique_ptr m_pFrame; }; /** diff --git a/registry/source/reflwrit.cxx b/registry/source/reflwrit.cxx index ced57265ddd9..747855850632 100644 --- a/registry/source/reflwrit.cxx +++ b/registry/source/reflwrit.cxx @@ -702,8 +702,7 @@ TypeWriter::TypeWriter(typereg_Version version, TypeWriter::~TypeWriter() { - if (m_superTypeNames) - delete[] m_superTypeNames; + delete[] m_superTypeNames; if (m_fieldCount) delete[] m_fields; @@ -714,8 +713,7 @@ TypeWriter::~TypeWriter() if (m_referenceCount) delete[] m_references; - if (m_pUik) - delete m_pUik; + delete m_pUik; } void TypeWriter::setSuperType(sal_uInt16 index, OString const & name) diff --git a/sc/inc/dptabsrc.hxx b/sc/inc/dptabsrc.hxx index c46a164ea89d..af44e96b008c 100644 --- a/sc/inc/dptabsrc.hxx +++ b/sc/inc/dptabsrc.hxx @@ -234,7 +234,8 @@ class ScDPDimensions : public cppu::WeakImplHelper< private: ScDPSource* pSource; long nDimCount; - rtl::Reference* ppDims; + std::unique_ptr[]> + ppDims; public: ScDPDimensions( ScDPSource* pSrc ); @@ -354,7 +355,8 @@ private: // date columns have 3 hierarchies (flat/quarter/week), other columns only one // #i52547# don't offer the incomplete date hierarchy implementation static const long nHierCount = 1; - rtl::Reference* ppHiers; + std::unique_ptr[]> + ppHiers; public: ScDPHierarchies( ScDPSource* pSrc, long nD ); @@ -418,7 +420,8 @@ private: long nDim; long nHier; long nLevCount; - rtl::Reference* ppLevs; + std::unique_ptr[]> + ppLevs; public: ScDPLevels( ScDPSource* pSrc, long nD, long nH ); 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(this)->ppDims = new rtl::Reference[nDimCount]; + const_cast(this)->ppDims.reset(new rtl::Reference[nDimCount] ); for (long i=0; i(this)->ppHiers = new rtl::Reference[nHierCount]; + const_cast(this)->ppHiers.reset( new rtl::Reference[nHierCount] ); for (long i=0; i(this)->ppLevs = new rtl::Reference[nLevCount]; + const_cast(this)->ppLevs.reset(new rtl::Reference[nLevCount] ); for (long i=0; iSetState( 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& 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()); - 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()); - 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()); - 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()); - 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; } diff --git a/scripting/source/provider/BrowseNodeFactoryImpl.cxx b/scripting/source/provider/BrowseNodeFactoryImpl.cxx index 773c210a7412..daaab0238454 100644 --- a/scripting/source/provider/BrowseNodeFactoryImpl.cxx +++ b/scripting/source/provider/BrowseNodeFactoryImpl.cxx @@ -44,6 +44,8 @@ #include #include +#include + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::script; @@ -165,7 +167,7 @@ class LocationBrowseNode : public ::cppu::WeakImplHelper< browse::XBrowseNode > { private: - BrowseNodeAggregatorHash* m_hBNA; + std::unique_ptr m_hBNA; vString m_vStr; OUString m_sNodeName; Reference< browse::XBrowseNode > m_origNode; @@ -179,18 +181,9 @@ public: m_origNode.set( node ); } - virtual ~LocationBrowseNode() override - { - if (m_hBNA) - { - delete m_hBNA; - } - } - // XBrowseNode - virtual OUString SAL_CALL getName() override { return m_sNodeName; @@ -231,7 +224,7 @@ private: void loadChildNodes() { - m_hBNA = new BrowseNodeAggregatorHash; + m_hBNA.reset( new BrowseNodeAggregatorHash ); Sequence< Reference< browse::XBrowseNode > > langNodes = m_origNode->getChildNodes(); diff --git a/scripting/source/provider/MasterScriptProvider.cxx b/scripting/source/provider/MasterScriptProvider.cxx index 0b4baeddd981..1e26f272d2fc 100644 --- a/scripting/source/provider/MasterScriptProvider.cxx +++ b/scripting/source/provider/MasterScriptProvider.cxx @@ -80,11 +80,6 @@ MasterScriptProvider::MasterScriptProvider( const Reference< XComponentContext > MasterScriptProvider::~MasterScriptProvider() { - if ( m_pPCache ) - { - delete m_pPCache; - } - m_pPCache = nullptr; } @@ -362,15 +357,15 @@ MasterScriptProvider::providerCache() if ( !m_bIsPkgMSP ) { - m_pPCache = new ProviderCache( m_xContext, m_sAargs ); + m_pPCache.reset( new ProviderCache( m_xContext, m_sAargs ) ); } else { - m_pPCache = new ProviderCache( m_xContext, m_sAargs, blacklist ); + m_pPCache.reset( new ProviderCache( m_xContext, m_sAargs, blacklist ) ); } } } - return m_pPCache; + return m_pPCache.get(); } diff --git a/scripting/source/provider/MasterScriptProvider.hxx b/scripting/source/provider/MasterScriptProvider.hxx index a77642587dd9..98644722393c 100644 --- a/scripting/source/provider/MasterScriptProvider.hxx +++ b/scripting/source/provider/MasterScriptProvider.hxx @@ -35,6 +35,7 @@ #include #include "ProviderCache.hxx" +#include namespace func_provider { @@ -120,7 +121,7 @@ private: bool m_bInitialised; bool m_bIsPkgMSP; css::uno::Reference< css::script::provider::XScriptProvider > m_xMSPPkg; - ProviderCache* m_pPCache; + std::unique_ptr m_pPCache; osl::Mutex m_mutex; OUString m_sCtxString; }; diff --git a/sd/source/filter/eppt/pptx-grouptable.cxx b/sd/source/filter/eppt/pptx-grouptable.cxx index 2e092220cb3c..712de6ac694f 100644 --- a/sd/source/filter/eppt/pptx-grouptable.cxx +++ b/sd/source/filter/eppt/pptx-grouptable.cxx @@ -45,8 +45,7 @@ void GroupTable::ImplResizeGroupTable( sal_uInt32 nEntrys ) GroupEntry** pTemp = new GroupEntry*[ nEntrys ]; for ( sal_uInt32 i = 0; i < mnCurrentGroupEntry; i++ ) pTemp[ i ] = mpGroupEntry[ i ]; - if ( mpGroupEntry ) - delete[] mpGroupEntry; + delete[] mpGroupEntry; mpGroupEntry = pTemp; } } diff --git a/sd/source/ui/sidebar/MasterPagesSelector.cxx b/sd/source/ui/sidebar/MasterPagesSelector.cxx index 359b5ad5eda2..edd6d0f19414 100644 --- a/sd/source/ui/sidebar/MasterPagesSelector.cxx +++ b/sd/source/ui/sidebar/MasterPagesSelector.cxx @@ -591,8 +591,7 @@ void MasterPagesSelector::ClearPageSet() for (size_t nIndex=1; nIndex<=PreviewValueSet::GetItemCount(); nIndex++) { UserData* pData = GetUserData(nIndex); - if (pData != nullptr) - delete pData; + delete pData; } PreviewValueSet::Clear(); } diff --git a/sd/source/ui/view/OutlinerIterator.cxx b/sd/source/ui/view/OutlinerIterator.cxx index 0126a1d3a57b..88c66acb4ca4 100644 --- a/sd/source/ui/view/OutlinerIterator.cxx +++ b/sd/source/ui/view/OutlinerIterator.cxx @@ -684,8 +684,7 @@ void ViewIteratorImpl::Reverse() IteratorImplBase::Reverse (); // Create reversed object list iterator. - if (mpObjectIterator != nullptr) - delete mpObjectIterator; + delete mpObjectIterator; if (mpPage != nullptr) mpObjectIterator = new SdrObjListIter(*mpPage, SdrIterMode::DeepNoGroups, ! mbDirectionIsForward); else diff --git a/sd/source/ui/view/drviewsc.cxx b/sd/source/ui/view/drviewsc.cxx index 9f245cc9aa52..5bbf7ff27c49 100644 --- a/sd/source/ui/view/drviewsc.cxx +++ b/sd/source/ui/view/drviewsc.cxx @@ -76,10 +76,7 @@ void DrawViewShell::UpdateIMapDlg( SdrObject* pObj ) SvxIMapDlgChildWindow::UpdateIMapDlg( aGraphic, pIMap, pTargetList, pObj ); // We can delete the target list - if ( pTargetList ) - { - delete pTargetList; - } + delete pTargetList; } } diff --git a/sd/source/ui/view/viewshel.cxx b/sd/source/ui/view/viewshel.cxx index 61dd557f5d07..75e61456b181 100644 --- a/sd/source/ui/view/viewshel.cxx +++ b/sd/source/ui/view/viewshel.cxx @@ -1683,8 +1683,7 @@ SfxShell* ViewShellObjectBarFactory::CreateShell( ::sd::ShellId nId ) void ViewShellObjectBarFactory::ReleaseShell (SfxShell* pShell) { - if (pShell != nullptr) - delete pShell; + delete pShell; } } // end of anonymous namespace diff --git a/sfx2/source/control/request.cxx b/sfx2/source/control/request.cxx index 77a7e4d6d5d7..b9bcabb547a6 100644 --- a/sfx2/source/control/request.cxx +++ b/sfx2/source/control/request.cxx @@ -419,8 +419,7 @@ void SfxRequest::RemoveItem( sal_uInt16 nID ) void SfxRequest::SetReturnValue(const SfxPoolItem &rItem) { DBG_ASSERT(!pImpl->pRetVal, "Set Return value multiple times?"); - if(pImpl->pRetVal) - delete pImpl->pRetVal; + delete pImpl->pRetVal; pImpl->pRetVal = rItem.Clone(); } diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 8f8059e25571..b86dba5a7d58 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -3470,8 +3470,7 @@ void SfxMedium::CreateTempFile( bool bReplace ) void SfxMedium::CreateTempFileNoCopy() { // this call always replaces the existing temporary file - if ( pImpl->pTempFile ) - delete pImpl->pTempFile; + delete pImpl->pTempFile; pImpl->pTempFile = new ::utl::TempFile(); pImpl->pTempFile->EnableKillingFile(); diff --git a/svgio/source/svgreader/svgnode.cxx b/svgio/source/svgreader/svgnode.cxx index 15cb099537b0..de546314956c 100644 --- a/svgio/source/svgreader/svgnode.cxx +++ b/svgio/source/svgreader/svgnode.cxx @@ -296,20 +296,9 @@ namespace svgio maChildren.pop_back(); } - if(mpId) - { - delete mpId; - } - - if(mpClass) - { - delete mpClass; - } - - if(mpLocalCssStyle) - { - delete mpLocalCssStyle; - } + delete mpId; + delete mpClass; + delete mpLocalCssStyle; } void SvgNode::readLocalCssStyle(const OUString& aContent) diff --git a/svx/inc/sdr/contact/viewobjectcontactofgraphic.hxx b/svx/inc/sdr/contact/viewobjectcontactofgraphic.hxx index 75ecbf65dc2a..46f6e4d32988 100644 --- a/svx/inc/sdr/contact/viewobjectcontactofgraphic.hxx +++ b/svx/inc/sdr/contact/viewobjectcontactofgraphic.hxx @@ -21,6 +21,7 @@ #define INCLUDED_SVX_INC_SDR_CONTACT_VIEWOBJECTCONTACTOFGRAPHIC_HXX #include +#include class SdrGrafObj; @@ -40,7 +41,7 @@ namespace sdr // Member which takes care for the asynch loading events which may be necessary // for asynch graphics loading. - sdr::event::AsynchGraphicLoadingEvent* mpAsynchLoadEvent; + std::unique_ptr mpAsynchLoadEvent; // async graphics loading helpers. Only to be used internally or from the // event helper class (in .cxx file) diff --git a/svx/source/sdr/contact/viewobjectcontactofgraphic.cxx b/svx/source/sdr/contact/viewobjectcontactofgraphic.cxx index 3b42c3837ebe..16c15b41909b 100644 --- a/svx/source/sdr/contact/viewobjectcontactofgraphic.cxx +++ b/svx/source/sdr/contact/viewobjectcontactofgraphic.cxx @@ -112,7 +112,7 @@ namespace sdr // Trigger asynchronious SwapIn. sdr::event::TimerEventHandler& rEventHandler = rObjectContact.GetEventHandler(); - mpAsynchLoadEvent = new sdr::event::AsynchGraphicLoadingEvent(rEventHandler, *this); + mpAsynchLoadEvent.reset( new sdr::event::AsynchGraphicLoadingEvent(rEventHandler, *this) ); } } else @@ -142,7 +142,7 @@ namespace sdr { // just delete it, this will remove it from the EventHandler and // will trigger forgetAsynchGraphicLoadingEvent from the destructor - delete mpAsynchLoadEvent; + mpAsynchLoadEvent.reset(); // Invalidate paint areas. // [1] If a calc document with graphics is loaded then OnLoad will @@ -222,7 +222,7 @@ namespace sdr if(mpAsynchLoadEvent) { - OSL_ENSURE(!pEvent || mpAsynchLoadEvent == pEvent, + OSL_ENSURE(!pEvent || mpAsynchLoadEvent.get() == pEvent, "ViewObjectContactOfGraphic::forgetAsynchGraphicLoadingEvent: Forced to forget another event then I have scheduled (?)"); // forget event @@ -302,13 +302,6 @@ namespace sdr ViewObjectContactOfGraphic::~ViewObjectContactOfGraphic() { - // evtl. delete the asynch loading event - if(mpAsynchLoadEvent) - { - // just delete it, this will remove it from the EventHandler and - // will trigger forgetAsynchGraphicLoadingEvent from the destructor - delete mpAsynchLoadEvent; - } } } // end of namespace contact } // end of namespace sdr diff --git a/svx/source/sdr/properties/textproperties.cxx b/svx/source/sdr/properties/textproperties.cxx index 8cc07bdd9353..b2d840c763fe 100644 --- a/svx/source/sdr/properties/textproperties.cxx +++ b/svx/source/sdr/properties/textproperties.cxx @@ -337,10 +337,7 @@ namespace sdr } } - if(pTempSet) - { - delete pTempSet; - } + delete pTempSet; } OutlinerParaObject* pTemp = rOutliner.CreateParaObject(0, nParaCount); diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx index ff71c07db5bb..2657375f311a 100644 --- a/svx/source/svdraw/svdedxv.cxx +++ b/svx/source/svdraw/svdedxv.cxx @@ -991,10 +991,7 @@ bool SdrObjEditView::SdrBeginTextEdit( pGivenOutlinerView = nullptr; } } - if( pTextEditOutliner!=nullptr ) - { - delete pTextEditOutliner; - } + delete pTextEditOutliner; pTextEditOutliner=nullptr; pTextEditOutlinerView=nullptr; diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx index 0c3dad0cd56f..d4f5ef2e824c 100644 --- a/svx/source/svdraw/svdopath.cxx +++ b/svx/source/svdraw/svdopath.cxx @@ -52,6 +52,7 @@ #include #include #include +#include using namespace sdr; @@ -501,12 +502,12 @@ class ImpPathForDragAndCreate SdrPathObj& mrSdrPathObject; XPolyPolygon aPathPolygon; SdrObjKind meObjectKind; - ImpSdrPathDragData* mpSdrPathDragData; + std::unique_ptr + mpSdrPathDragData; bool mbCreating; public: explicit ImpPathForDragAndCreate(SdrPathObj& rSdrPathObject); - ~ImpPathForDragAndCreate(); // drag stuff bool beginPathDrag( SdrDragStat& rDrag ) const; @@ -544,14 +545,6 @@ ImpPathForDragAndCreate::ImpPathForDragAndCreate(SdrPathObj& rSdrPathObject) { } -ImpPathForDragAndCreate::~ImpPathForDragAndCreate() -{ - if(mpSdrPathDragData) - { - delete mpSdrPathDragData; - } -} - bool ImpPathForDragAndCreate::beginPathDrag( SdrDragStat& rDrag ) const { const SdrHdl* pHdl=rDrag.GetHdl(); @@ -585,13 +578,12 @@ bool ImpPathForDragAndCreate::beginPathDrag( SdrDragStat& rDrag ) const bMultiPointDrag = false; } - const_cast(this)->mpSdrPathDragData = new ImpSdrPathDragData(mrSdrPathObject,*pHdl,bMultiPointDrag,rDrag); + const_cast(this)->mpSdrPathDragData.reset( new ImpSdrPathDragData(mrSdrPathObject,*pHdl,bMultiPointDrag,rDrag) ); if(!mpSdrPathDragData || !mpSdrPathDragData->bValid) { OSL_FAIL("ImpPathForDragAndCreate::BegDrag(): ImpSdrPathDragData is invalid."); - delete mpSdrPathDragData; - const_cast(this)->mpSdrPathDragData = nullptr; + const_cast(this)->mpSdrPathDragData.reset(); return false; } @@ -915,8 +907,7 @@ bool ImpPathForDragAndCreate::endPathDrag(SdrDragStat& rDrag) } } - delete mpSdrPathDragData; - mpSdrPathDragData = nullptr; + mpSdrPathDragData.reset(); return true; } @@ -992,7 +983,7 @@ OUString ImpPathForDragAndCreate::getSpecialDragComment(const SdrDragStat& rDrag else { // #i103058# standard for modification; model and handle needed - ImpSdrPathDragData* pDragData = mpSdrPathDragData; + ImpSdrPathDragData* pDragData = mpSdrPathDragData.get(); if(!pDragData) { diff --git a/svx/source/svdraw/svdpagv.cxx b/svx/source/svdraw/svdpagv.cxx index a4d4c34d949a..c099553241e4 100644 --- a/svx/source/svdraw/svdpagv.cxx +++ b/svx/source/svdraw/svdpagv.cxx @@ -182,11 +182,7 @@ void SdrPageView::RemovePaintWindowFromPageView(SdrPaintWindow& rPaintWindow) if(pCandidate) { pCandidate = RemovePageWindow(*pCandidate); - - if(pCandidate) - { - delete pCandidate; - } + delete pCandidate; } } diff --git a/svx/source/svdraw/textchainflow.cxx b/svx/source/svdraw/textchainflow.cxx index 3f0f07dea1b8..559e6b9bd210 100644 --- a/svx/source/svdraw/textchainflow.cxx +++ b/svx/source/svdraw/textchainflow.cxx @@ -46,10 +46,8 @@ TextChainFlow::TextChainFlow(SdrTextObj *pChainTarget) TextChainFlow::~TextChainFlow() { - if (mpOverflChText) - delete mpOverflChText; - if (mpUnderflChText) - delete mpUnderflChText; + delete mpOverflChText; + delete mpUnderflChText; } void TextChainFlow::impSetFlowOutlinerParams(SdrOutliner *, SdrOutliner *) diff --git a/svx/source/xoutdev/xpool.cxx b/svx/source/xoutdev/xpool.cxx index ff064151105b..317ca98bc834 100644 --- a/svx/source/xoutdev/xpool.cxx +++ b/svx/source/xoutdev/xpool.cxx @@ -179,10 +179,7 @@ XOutdevItemPool::~XOutdevItemPool() // release and delete static pool default items ReleaseDefaults(true); - if(mpLocalItemInfos) - { - delete[] mpLocalItemInfos; - } + delete[] mpLocalItemInfos; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/doc/docsort.cxx b/sw/source/core/doc/docsort.cxx index e08b6987a8d5..945104ceaabc 100644 --- a/sw/source/core/doc/docsort.cxx +++ b/sw/source/core/doc/docsort.cxx @@ -771,9 +771,7 @@ FlatFndBox::~FlatFndBox() { FndBox_** ppTmp = const_cast(pArr); delete [] ppTmp; - - if( ppItemSets ) - delete [] ppItemSets; + delete [] ppItemSets; } /// All Lines of a Box need to have same number of Boxes diff --git a/sw/source/core/text/wrong.cxx b/sw/source/core/text/wrong.cxx index e7f4b0d85b47..6da8afc1f209 100644 --- a/sw/source/core/text/wrong.cxx +++ b/sw/source/core/text/wrong.cxx @@ -83,8 +83,7 @@ void SwWrongList::ClearList() { for (SwWrongArea & i : maList) { - if (i.mpSubList) - delete i.mpSubList; + delete i.mpSubList; i.mpSubList = nullptr; } maList.clear(); @@ -573,8 +572,7 @@ void SwWrongList::Remove(sal_uInt16 nIdx, sal_uInt16 nLen ) std::vector::iterator iLoop = i1; while ( iLoop != i2 ) { - if ( (*iLoop).mpSubList ) - delete (*iLoop).mpSubList; + delete (*iLoop).mpSubList; ++iLoop; } diff --git a/sw/source/core/undo/unins.cxx b/sw/source/core/undo/unins.cxx index 500185107abf..f6ff3e80ee4b 100644 --- a/sw/source/core/undo/unins.cxx +++ b/sw/source/core/undo/unins.cxx @@ -200,7 +200,7 @@ SwUndoInsert::~SwUndoInsert() rUNds.GetEndOfExtras().GetIndex() - m_pUndoNodeIndex->GetIndex()); m_pUndoNodeIndex.reset(); } - else if( pText ) // the inserted text + else // the inserted text delete pText; delete pRedlData; delete pUndoText; diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index 1954d3039307..88b6fca91adb 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -3396,10 +3396,7 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, OUString& rStr ) //The TOC field representation contents should be inserted into TOC section, but not after TOC section. //So we need update the document position when loading TOC representation and after loading TOC; - if (m_pPosAfterTOC) - { - delete m_pPosAfterTOC; - } + delete m_pPosAfterTOC; m_pPosAfterTOC = new SwPaM(*m_pPaM, m_pPaM); (*m_pPaM).Move(fnMoveBackward); SwPaM aRegion(*m_pPaM, m_pPaM); diff --git a/vcl/inc/unx/salobj.h b/vcl/inc/unx/salobj.h index ffc738aa6987..ba35beebf780 100644 --- a/vcl/inc/unx/salobj.h +++ b/vcl/inc/unx/salobj.h @@ -23,6 +23,7 @@ #include #include #include +#include class SalClipRegion { @@ -36,7 +37,7 @@ public: void UnionClipRegion( long nX, long nY, long nWidth, long nHeight ); XRectangle *EndSetClipRegion() { - return ClipRectangleList; } + return ClipRectangleList.get(); } void ResetClipRegion() { numClipRectangles = 0; } int GetRectangleCount() { @@ -44,7 +45,8 @@ public: private: - XRectangle* ClipRectangleList; + std::unique_ptr + ClipRectangleList; int numClipRectangles; int maxClipRectangles; }; diff --git a/vcl/source/gdi/metaact.cxx b/vcl/source/gdi/metaact.cxx index 1376476634c2..31b7d5fa5da9 100644 --- a/vcl/source/gdi/metaact.cxx +++ b/vcl/source/gdi/metaact.cxx @@ -3172,7 +3172,7 @@ MetaCommentAction::MetaCommentAction( const MetaCommentAction& rAct ) : maComment ( rAct.maComment ), mnValue ( rAct.mnValue ) { - ImplInitDynamicData( rAct.mpData, rAct.mnDataSize ); + ImplInitDynamicData( rAct.mpData.get(), rAct.mnDataSize ); } MetaCommentAction::MetaCommentAction( const OString& rComment, sal_Int32 nValue, const sal_uInt8* pData, sal_uInt32 nDataSize ) : @@ -3185,8 +3185,6 @@ MetaCommentAction::MetaCommentAction( const OString& rComment, sal_Int32 nValue, MetaCommentAction::~MetaCommentAction() { - if ( mpData ) - delete[] mpData; } void MetaCommentAction::ImplInitDynamicData( const sal_uInt8* pData, sal_uInt32 nDataSize ) @@ -3194,8 +3192,8 @@ void MetaCommentAction::ImplInitDynamicData( const sal_uInt8* pData, sal_uInt32 if ( nDataSize && pData ) { mnDataSize = nDataSize; - mpData = new sal_uInt8[ mnDataSize ]; - memcpy( mpData, pData, mnDataSize ); + mpData.reset( new sal_uInt8[ mnDataSize ] ); + memcpy( mpData.get(), pData, mnDataSize ); } else { @@ -3229,7 +3227,7 @@ void MetaCommentAction::Move( long nXMove, long nYMove ) bool bPathStroke = (maComment == "XPATHSTROKE_SEQ_BEGIN"); if ( bPathStroke || maComment == "XPATHFILL_SEQ_BEGIN" ) { - SvMemoryStream aMemStm( static_cast(mpData), mnDataSize, StreamMode::READ ); + SvMemoryStream aMemStm( static_cast(mpData.get()), mnDataSize, StreamMode::READ ); SvMemoryStream aDest; if ( bPathStroke ) { @@ -3265,7 +3263,7 @@ void MetaCommentAction::Move( long nXMove, long nYMove ) WriteSvtGraphicFill( aDest, aFill ); } - delete[] mpData; + mpData.reset(); ImplInitDynamicData( static_cast( aDest.GetData() ), aDest.Tell() ); } } @@ -3285,7 +3283,7 @@ void MetaCommentAction::Scale( double fXScale, double fYScale ) bool bPathStroke = (maComment == "XPATHSTROKE_SEQ_BEGIN"); if ( bPathStroke || maComment == "XPATHFILL_SEQ_BEGIN" ) { - SvMemoryStream aMemStm( static_cast(mpData), mnDataSize, StreamMode::READ ); + SvMemoryStream aMemStm( static_cast(mpData.get()), mnDataSize, StreamMode::READ ); SvMemoryStream aDest; if ( bPathStroke ) { @@ -3304,10 +3302,10 @@ void MetaCommentAction::Scale( double fXScale, double fYScale ) aFill.setPath( aPath ); WriteSvtGraphicFill( aDest, aFill ); } - delete[] mpData; + mpData.reset(); ImplInitDynamicData( static_cast( aDest.GetData() ), aDest.Tell() ); } else if( maComment == "EMF_PLUS_HEADER_INFO" ){ - SvMemoryStream aMemStm( static_cast(mpData), mnDataSize, StreamMode::READ ); + SvMemoryStream aMemStm( static_cast(mpData.get()), mnDataSize, StreamMode::READ ); SvMemoryStream aDest; sal_Int32 nLeft(0), nRight(0), nTop(0), nBottom(0); @@ -3345,7 +3343,7 @@ void MetaCommentAction::Write( SvStream& rOStm, ImplMetaWriteData* pData ) rOStm.WriteInt32( mnValue ).WriteUInt32( mnDataSize ); if ( mnDataSize ) - rOStm.WriteBytes( mpData, mnDataSize ); + rOStm.WriteBytes( mpData.get(), mnDataSize ); } void MetaCommentAction::Read( SvStream& rIStm, ImplMetaReadData* ) @@ -3363,15 +3361,13 @@ void MetaCommentAction::Read( SvStream& rIStm, ImplMetaReadData* ) SAL_INFO("vcl.gdi", "MetaCommentAction::Read " << maComment); - delete[] mpData; + mpData.reset(); if( mnDataSize ) { - mpData = new sal_uInt8[ mnDataSize ]; - rIStm.ReadBytes(mpData, mnDataSize); + mpData.reset(new sal_uInt8[ mnDataSize ]); + rIStm.ReadBytes(mpData.get(), mnDataSize); } - else - mpData = nullptr; } MetaLayoutModeAction::MetaLayoutModeAction() : diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx index b7d1a93b861b..79bdc4afc273 100644 --- a/vcl/source/opengl/OpenGLHelper.cxx +++ b/vcl/source/opengl/OpenGLHelper.cxx @@ -919,8 +919,7 @@ void OpenGLWatchdogThread::stop() gxWatchdog.clear(); } - if (gpWatchdogExit) - delete gpWatchdogExit; + delete gpWatchdogExit; gpWatchdogExit = nullptr; } diff --git a/vcl/source/window/accel.cxx b/vcl/source/window/accel.cxx index b0c7f912aaad..28c9844a5ffb 100644 --- a/vcl/source/window/accel.cxx +++ b/vcl/source/window/accel.cxx @@ -162,9 +162,7 @@ void Accelerator::ImplDeleteData() { // delete accelerator-entries using the id-table for (ImplAccelEntry* pEntry : mpData->maIdList) { - if ( pEntry->mpAutoAccel ) { - delete pEntry->mpAutoAccel; - } + delete pEntry->mpAutoAccel; delete pEntry; } mpData->maIdList.clear(); diff --git a/vcl/unx/generic/window/salframe.cxx b/vcl/unx/generic/window/salframe.cxx index 1744dc6e06bc..1ea8598c55f5 100644 --- a/vcl/unx/generic/window/salframe.cxx +++ b/vcl/unx/generic/window/salframe.cxx @@ -4136,8 +4136,7 @@ void X11SalFrame::ResetClipRegion() void X11SalFrame::BeginSetClipRegion( sal_uLong nRects ) { - if( m_pClipRectangles ) - delete [] m_pClipRectangles; + delete [] m_pClipRectangles; if( nRects ) m_pClipRectangles = new XRectangle[nRects]; else diff --git a/vcl/unx/generic/window/salobj.cxx b/vcl/unx/generic/window/salobj.cxx index 186af85cbe49..e3ec1b467290 100644 --- a/vcl/unx/generic/window/salobj.cxx +++ b/vcl/unx/generic/window/salobj.cxx @@ -187,17 +187,12 @@ SalClipRegion::SalClipRegion() SalClipRegion::~SalClipRegion() { - if ( ClipRectangleList ) - delete [] ClipRectangleList; } void SalClipRegion::BeginSetClipRegion( sal_uLong nRects ) { - if (ClipRectangleList) - delete [] ClipRectangleList; - - ClipRectangleList = new XRectangle[nRects]; + ClipRectangleList.reset( new XRectangle[nRects] ); numClipRectangles = 0; maxClipRectangles = nRects; } @@ -207,12 +202,12 @@ SalClipRegion::UnionClipRegion( long nX, long nY, long nWidth, long nHeight ) { if ( nWidth && nHeight && (numClipRectangles < maxClipRectangles) ) { - XRectangle *aRect = ClipRectangleList + numClipRectangles; + XRectangle& aRect = ClipRectangleList[numClipRectangles]; - aRect->x = (short) nX; - aRect->y = (short) nY; - aRect->width = (unsigned short) nWidth; - aRect->height= (unsigned short) nHeight; + aRect.x = (short) nX; + aRect.y = (short) nY; + aRect.width = (unsigned short) nWidth; + aRect.height= (unsigned short) nHeight; numClipRectangles++; } diff --git a/xmlscript/source/xml_helper/xml_impctx.cxx b/xmlscript/source/xml_helper/xml_impctx.cxx index 5b3f8ae1156a..18c1666d7d4c 100644 --- a/xmlscript/source/xml_helper/xml_impctx.cxx +++ b/xmlscript/source/xml_helper/xml_impctx.cxx @@ -85,8 +85,8 @@ class MGuard { Mutex * m_pMutex; public: - explicit MGuard( Mutex * pMutex ) - : m_pMutex( pMutex ) + explicit MGuard( std::unique_ptr const & pMutex ) + : m_pMutex( pMutex.get() ) { if (m_pMutex) m_pMutex->acquire(); } ~MGuard() throw () { if (m_pMutex) m_pMutex->release(); } @@ -118,7 +118,7 @@ class DocumentHandlerImpl : std::vector< ElementEntry * > m_elements; sal_Int32 m_nSkipElements; - Mutex * m_pMutex; + std::unique_ptr m_pMutex; inline Reference< xml::input::XElement > getCurrentElement() const; @@ -136,7 +136,6 @@ public: DocumentHandlerImpl( Reference< xml::input::XRoot > const & xRoot, bool bSingleThreadedUse ); - virtual ~DocumentHandlerImpl() throw () override; // XServiceInfo virtual OUString SAL_CALL getImplementationName() override; @@ -187,18 +186,7 @@ DocumentHandlerImpl::DocumentHandlerImpl( m_elements.reserve( 10 ); if (! bSingleThreadedUse) - m_pMutex = new Mutex(); -} - -DocumentHandlerImpl::~DocumentHandlerImpl() throw () -{ - if (m_pMutex != nullptr) - { - delete m_pMutex; -#if OSL_DEBUG_LEVEL == 0 - m_pMutex = nullptr; -#endif - } + m_pMutex.reset(new Mutex); } inline Reference< xml::input::XElement > -- cgit v1.2.3