summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-05-31 15:40:25 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-06-12 08:43:48 +0200
commite4e4d5713e248f02faf7aa6199b11e152973de8e (patch)
tree836dffa89d0a966e41b1af8270db74b9590def22 /vcl
parentd4eabd5da8ea3b5ac40659c22cde19b26b3c002b (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 'vcl')
-rw-r--r--vcl/inc/unx/salobj.h6
-rw-r--r--vcl/source/gdi/metaact.cxx28
-rw-r--r--vcl/source/opengl/OpenGLHelper.cxx3
-rw-r--r--vcl/source/window/accel.cxx4
-rw-r--r--vcl/unx/generic/window/salframe.cxx3
-rw-r--r--vcl/unx/generic/window/salobj.cxx17
6 files changed, 25 insertions, 36 deletions
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 <salobj.hxx>
#include <vcl/sysdata.hxx>
#include <vclpluginapi.h>
+#include <memory>
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<XRectangle[]>
+ 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<void*>(mpData), mnDataSize, StreamMode::READ );
+ SvMemoryStream aMemStm( static_cast<void*>(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<const sal_uInt8*>( 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<void*>(mpData), mnDataSize, StreamMode::READ );
+ SvMemoryStream aMemStm( static_cast<void*>(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<const sal_uInt8*>( aDest.GetData() ), aDest.Tell() );
} else if( maComment == "EMF_PLUS_HEADER_INFO" ){
- SvMemoryStream aMemStm( static_cast<void*>(mpData), mnDataSize, StreamMode::READ );
+ SvMemoryStream aMemStm( static_cast<void*>(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++;
}