summaryrefslogtreecommitdiff
path: root/vcl/unx
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2014-03-09 00:44:27 +0900
committerTakeshi Abe <tabe@fixedpoint.jp>2014-03-09 05:17:41 +0900
commit06024a58e01a41fe5ce5af38b7714ea6c66a6832 (patch)
treea1c3415fc7ca5581c610838e7865c5f9c9184cda /vcl/unx
parent54195c53a915b28302bf36333d2b328e57881b30 (diff)
Avoid possible resource leaks with boost::scoped_ptr
Change-Id: Ic6e8482dfb022f32532b5c1a6e045092c3485106
Diffstat (limited to 'vcl/unx')
-rw-r--r--vcl/unx/generic/gdi/salbmp.cxx19
-rw-r--r--vcl/unx/generic/gdi/salgdi2.cxx11
2 files changed, 15 insertions, 15 deletions
diff --git a/vcl/unx/generic/gdi/salbmp.cxx b/vcl/unx/generic/gdi/salbmp.cxx
index d748e6a94ce6..7e7aef3cf911 100644
--- a/vcl/unx/generic/gdi/salbmp.cxx
+++ b/vcl/unx/generic/gdi/salbmp.cxx
@@ -48,6 +48,7 @@
#include <valgrind/memcheck.h>
#endif
+#include <boost/scoped_ptr.hpp>
// - SalBitmap -
@@ -426,8 +427,8 @@ XImage* X11SalBitmap::ImplCreateXImage(
{
BitmapBuffer* pDstBuf;
sal_uLong nDstFormat = BMP_FORMAT_TOP_DOWN;
- BitmapPalette* pPal = NULL;
- ColorMask* pMask = NULL;
+ boost::scoped_ptr<BitmapPalette> pPal;
+ boost::scoped_ptr<ColorMask> pMask;
switch( pImage->bits_per_pixel )
{
@@ -466,7 +467,7 @@ XImage* X11SalBitmap::ImplCreateXImage(
#endif
- pMask = new ColorMask( pImage->red_mask, pImage->green_mask, pImage->blue_mask );
+ pMask.reset(new ColorMask( pImage->red_mask, pImage->green_mask, pImage->blue_mask ));
}
break;
@@ -497,13 +498,13 @@ XImage* X11SalBitmap::ImplCreateXImage(
if( pImage->depth == 1 )
{
- pPal = new BitmapPalette( 2 );
+ pPal.reset(new BitmapPalette( 2 ));
(*pPal)[ 0 ] = Color( COL_BLACK );
(*pPal)[ 1 ] = Color( COL_WHITE );
}
else if( pImage->depth == 8 && mbGrey )
{
- pPal = new BitmapPalette( 256 );
+ pPal.reset(new BitmapPalette( 256 ));
for( sal_uInt16 i = 0; i < 256; i++ )
{
@@ -522,7 +523,7 @@ XImage* X11SalBitmap::ImplCreateXImage(
, (sal_uLong)(1 << pImage->depth)
);
- pPal = new BitmapPalette( nCols );
+ pPal.reset(new BitmapPalette( nCols ));
for( sal_uInt16 i = 0; i < nCols; i++ )
{
@@ -535,9 +536,9 @@ XImage* X11SalBitmap::ImplCreateXImage(
}
}
- pDstBuf = StretchAndConvert( *mpDIB, rTwoRect, nDstFormat, pPal, pMask );
- delete pPal;
- delete pMask;
+ pDstBuf = StretchAndConvert( *mpDIB, rTwoRect, nDstFormat, pPal.get(), pMask.get() );
+ pPal.reset();
+ pMask.reset();
if( pDstBuf && pDstBuf->mpBits )
{
diff --git a/vcl/unx/generic/gdi/salgdi2.cxx b/vcl/unx/generic/gdi/salgdi2.cxx
index e4b853f2eb99..66eecb4a389e 100644
--- a/vcl/unx/generic/gdi/salgdi2.cxx
+++ b/vcl/unx/generic/gdi/salgdi2.cxx
@@ -37,6 +37,7 @@
#include "vcl/bmpacc.hxx"
#include <outdata.hxx>
+#include <boost/scoped_ptr.hpp>
#undef SALGDI2_TESTTRANS
@@ -400,10 +401,10 @@ void X11SalGraphics::copyBits( const SalTwoRect& rPosAry,
// #i60699# No chance to handle graphics exposures - we copy
// to a temp bitmap first, into which no repaints are
// technically possible.
- SalBitmap *pDDB = pSrcGraphics->getBitmap( rPosAry.mnSrcX,
- rPosAry.mnSrcY,
- rPosAry.mnSrcWidth,
- rPosAry.mnSrcHeight );
+ boost::scoped_ptr<SalBitmap> pDDB(pSrcGraphics->getBitmap( rPosAry.mnSrcX,
+ rPosAry.mnSrcY,
+ rPosAry.mnSrcWidth,
+ rPosAry.mnSrcHeight ));
if( !pDDB )
{
@@ -415,8 +416,6 @@ void X11SalGraphics::copyBits( const SalTwoRect& rPosAry,
aPosAry.mnSrcX = 0, aPosAry.mnSrcY = 0;
drawBitmap( aPosAry, *pDDB );
-
- delete pDDB;
}
else {
stderr0( "X11SalGraphics::CopyBits from Printer not yet implemented\n" );