diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2014-03-09 00:44:27 +0900 |
---|---|---|
committer | Takeshi Abe <tabe@fixedpoint.jp> | 2014-03-09 05:17:41 +0900 |
commit | 06024a58e01a41fe5ce5af38b7714ea6c66a6832 (patch) | |
tree | a1c3415fc7ca5581c610838e7865c5f9c9184cda | |
parent | 54195c53a915b28302bf36333d2b328e57881b30 (diff) |
Avoid possible resource leaks with boost::scoped_ptr
Change-Id: Ic6e8482dfb022f32532b5c1a6e045092c3485106
-rw-r--r-- | vcl/source/gdi/gfxlink.cxx | 9 | ||||
-rw-r--r-- | vcl/source/gdi/impanmvw.cxx | 10 | ||||
-rw-r--r-- | vcl/source/gdi/impgraph.cxx | 27 | ||||
-rw-r--r-- | vcl/source/gdi/impvect.cxx | 22 | ||||
-rw-r--r-- | vcl/source/gdi/outdev4.cxx | 19 | ||||
-rw-r--r-- | vcl/source/gdi/outdev6.cxx | 19 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl2.cxx | 15 | ||||
-rw-r--r-- | vcl/unx/generic/gdi/salbmp.cxx | 19 | ||||
-rw-r--r-- | vcl/unx/generic/gdi/salgdi2.cxx | 11 |
9 files changed, 70 insertions, 81 deletions
diff --git a/vcl/source/gdi/gfxlink.cxx b/vcl/source/gdi/gfxlink.cxx index 1d726bae9dd5..3d6ba2951f19 100644 --- a/vcl/source/gdi/gfxlink.cxx +++ b/vcl/source/gdi/gfxlink.cxx @@ -28,6 +28,7 @@ #include <vcl/gfxlink.hxx> #include <vcl/cvtgrf.hxx> #include <com/sun/star/ucb/CommandAbortedException.hpp> +#include <boost/scoped_ptr.hpp> GfxLink::GfxLink() : meType ( GFX_LINK_TYPE_NONE ), @@ -346,12 +347,12 @@ ImpSwap::ImpSwap( sal_uInt8* pData, sal_uLong nDataSize ) : maURL = aTempFile.GetURL(); if( !maURL.isEmpty() ) { - SvStream* pOStm = ::utl::UcbStreamHelper::CreateStream( maURL, STREAM_READWRITE | STREAM_SHARE_DENYWRITE ); + boost::scoped_ptr<SvStream> pOStm(::utl::UcbStreamHelper::CreateStream( maURL, STREAM_READWRITE | STREAM_SHARE_DENYWRITE )); if( pOStm ) { pOStm->Write( pData, mnDataSize ); bool bError = ( ERRCODE_NONE != pOStm->GetError() ); - delete pOStm; + pOStm.reset(); if( bError ) { @@ -375,7 +376,7 @@ sal_uInt8* ImpSwap::GetData() const if( IsSwapped() ) { - SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( maURL, STREAM_READWRITE ); + boost::scoped_ptr<SvStream> pIStm(::utl::UcbStreamHelper::CreateStream( maURL, STREAM_READWRITE )); if( pIStm ) { pData = new sal_uInt8[ mnDataSize ]; @@ -386,7 +387,7 @@ sal_uInt8* ImpSwap::GetData() const { bError = true; } - delete pIStm; + pIStm.reset(); if( bError ) delete[] pData, pData = NULL; diff --git a/vcl/source/gdi/impanmvw.cxx b/vcl/source/gdi/impanmvw.cxx index 5a5453045dc7..ee34d1fdeefd 100644 --- a/vcl/source/gdi/impanmvw.cxx +++ b/vcl/source/gdi/impanmvw.cxx @@ -22,6 +22,7 @@ #include <vcl/virdev.hxx> #include <vcl/window.hxx> #include <tools/helpers.hxx> +#include <boost/scoped_ptr.hpp> ImplAnimView::ImplAnimView( Animation* pParent, OutputDevice* pOut, const Point& rPt, const Size& rSz, @@ -155,7 +156,7 @@ void ImplAnimView::ImplGetPosSize( const AnimationBitmap& rAnm, Point& rPosPix, void ImplAnimView::ImplDrawToPos( sal_uLong nPos ) { VirtualDevice aVDev; - Region* pOldClip = !maClip.IsNull() ? new Region( mpOut->GetClipRegion() ) : NULL; + boost::scoped_ptr<Region> pOldClip(!maClip.IsNull() ? new Region( mpOut->GetClipRegion() ) : NULL); aVDev.SetOutputSizePixel( maSzPix, false ); nPos = std::min( nPos, (sal_uLong) mpParent->Count() - 1UL ); @@ -169,10 +170,7 @@ void ImplAnimView::ImplDrawToPos( sal_uLong nPos ) mpOut->DrawOutDev( maDispPt, maDispSz, Point(), maSzPix, aVDev ); if( pOldClip ) - { mpOut->SetClipRegion( *pOldClip ); - delete pOldClip; - } } void ImplAnimView::ImplDraw( sal_uLong nPos ) @@ -269,7 +267,7 @@ void ImplAnimView::ImplDraw( sal_uLong nPos, VirtualDevice* pVDev ) if( !pVDev ) { - Region* pOldClip = !maClip.IsNull() ? new Region( mpOut->GetClipRegion() ) : NULL; + boost::scoped_ptr<Region> pOldClip(!maClip.IsNull() ? new Region( mpOut->GetClipRegion() ) : NULL); if( pOldClip ) mpOut->SetClipRegion( maClip ); @@ -279,7 +277,7 @@ void ImplAnimView::ImplDraw( sal_uLong nPos, VirtualDevice* pVDev ) if( pOldClip ) { mpOut->SetClipRegion( *pOldClip ); - delete pOldClip; + pOldClip.reset(); } delete pDev; diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index a118405827f2..7f346cf42d3b 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -37,6 +37,7 @@ #include <impgraph.hxx> #include <com/sun/star/ucb/CommandAbortedException.hpp> #include <vcl/dibtools.hxx> +#include <boost/scoped_ptr.hpp> #define GRAPHIC_MAXPARTLEN 256000L #define GRAPHIC_MTFTOBMP_MAXEXT 2048 @@ -1097,10 +1098,10 @@ bool ImpGraphic::ImplReadEmbedded( SvStream& rIStm, bool bSwap ) if( !aTmpURL.GetMainURL( INetURLObject::NO_DECODE ).isEmpty() ) { - SvStream* pOStm = NULL; + boost::scoped_ptr<SvStream> pOStm; try { - pOStm = ::utl::UcbStreamHelper::CreateStream( aTmpURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READWRITE | STREAM_SHARE_DENYWRITE ); + pOStm.reset(::utl::UcbStreamHelper::CreateStream( aTmpURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READWRITE | STREAM_SHARE_DENYWRITE )); } catch( const ::com::sun::star::uno::Exception& ) { @@ -1131,7 +1132,7 @@ bool ImpGraphic::ImplReadEmbedded( SvStream& rIStm, bool bSwap ) rtl_freeMemory( pBuffer ); sal_uLong nReadErr = rIStm.GetError(), nWriteErr = pOStm->GetError(); - delete pOStm, pOStm = NULL; + pOStm.reset(); if( !nReadErr && !nWriteErr ) { @@ -1165,8 +1166,6 @@ bool ImpGraphic::ImplReadEmbedded( SvStream& rIStm, bool bSwap ) } } } - - delete pOStm; } } } @@ -1309,10 +1308,10 @@ bool ImpGraphic::ImplSwapOut() if( !aTmpURL.GetMainURL( INetURLObject::NO_DECODE ).isEmpty() ) { - SvStream* pOStm = NULL; + boost::scoped_ptr<SvStream> pOStm; try { - pOStm = ::utl::UcbStreamHelper::CreateStream( aTmpURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READWRITE | STREAM_SHARE_DENYWRITE ); + pOStm.reset(::utl::UcbStreamHelper::CreateStream( aTmpURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READWRITE | STREAM_SHARE_DENYWRITE )); } catch( const ::com::sun::star::uno::Exception& ) { @@ -1322,7 +1321,7 @@ bool ImpGraphic::ImplSwapOut() pOStm->SetVersion( SOFFICE_FILEFORMAT_50 ); pOStm->SetCompressMode( COMPRESSMODE_NATIVE ); - if( ( bRet = ImplSwapOut( pOStm ) ) ) + if( ( bRet = ImplSwapOut( pOStm.get() ) ) ) { mpSwapFile = new ImpSwapFile; mpSwapFile->nRefCount = 1; @@ -1330,7 +1329,7 @@ bool ImpGraphic::ImplSwapOut() } else { - delete pOStm, pOStm = NULL; + pOStm.reset(); try { @@ -1354,8 +1353,6 @@ bool ImpGraphic::ImplSwapOut() { } } - - delete pOStm; } } } @@ -1412,10 +1409,10 @@ bool ImpGraphic::ImplSwapIn() if( !aSwapURL.isEmpty() ) { - SvStream* pIStm = NULL; + boost::scoped_ptr<SvStream> pIStm; try { - pIStm = ::utl::UcbStreamHelper::CreateStream( aSwapURL, STREAM_READWRITE | STREAM_SHARE_DENYWRITE ); + pIStm.reset(::utl::UcbStreamHelper::CreateStream( aSwapURL, STREAM_READWRITE | STREAM_SHARE_DENYWRITE )); } catch( const ::com::sun::star::uno::Exception& ) { @@ -1429,8 +1426,8 @@ bool ImpGraphic::ImplSwapIn() if( !mpSwapFile ) pIStm->Seek( mnDocFilePos ); - bRet = ImplSwapIn( pIStm ); - delete pIStm; + bRet = ImplSwapIn( pIStm.get() ); + pIStm.reset(); if( mpSwapFile ) { diff --git a/vcl/source/gdi/impvect.cxx b/vcl/source/gdi/impvect.cxx index aa2c022c84c1..739fc8ad5597 100644 --- a/vcl/source/gdi/impvect.cxx +++ b/vcl/source/gdi/impvect.cxx @@ -27,6 +27,7 @@ #include <vcl/wrkwin.hxx> #include <vcl/virdev.hxx> #include <impvect.hxx> +#include <boost/scoped_ptr.hpp> #define VECT_POLY_MAX 8192 @@ -646,7 +647,7 @@ bool ImplVectorizer::ImplVectorize( const Bitmap& rColorBmp, GDIMetaFile& rMtf, VECT_PROGRESS( pProgress, 0 ); - Bitmap* pBmp = new Bitmap( rColorBmp ); + boost::scoped_ptr<Bitmap> pBmp(new Bitmap( rColorBmp )); BitmapReadAccess* pRAcc = pBmp->AcquireReadAccess(); if( pRAcc ) @@ -690,15 +691,15 @@ bool ImplVectorizer::ImplVectorize( const Bitmap& rColorBmp, GDIMetaFile& rMtf, const BitmapColor aBmpCol( pRAcc->GetPaletteColor( pColorSet[ i ].mnIndex ) ); const Color aFindColor( aBmpCol.GetRed(), aBmpCol.GetGreen(), aBmpCol.GetBlue() ); // const sal_uInt8 cLum = aFindColor.GetLuminance(); - ImplVectMap* pMap = ImplExpand( pRAcc, aFindColor ); + boost::scoped_ptr<ImplVectMap> pMap(ImplExpand( pRAcc, aFindColor )); VECT_PROGRESS( pProgress, FRound( fPercent += fPercentStep_2 ) ); if( pMap ) { aPolyPoly.Clear(); - ImplCalculate( pMap, aPolyPoly, cReduce, nFlags ); - delete pMap; + ImplCalculate( pMap.get(), aPolyPoly, cReduce, nFlags ); + pMap.reset(); if( aPolyPoly.Count() ) { @@ -736,7 +737,7 @@ bool ImplVectorizer::ImplVectorize( const Bitmap& rColorBmp, GDIMetaFile& rMtf, } pBmp->ReleaseAccess( pRAcc ); - delete pBmp; + pBmp.reset(); VECT_PROGRESS( pProgress, 100 ); return bRet; @@ -746,9 +747,8 @@ bool ImplVectorizer::ImplVectorize( const Bitmap& rMonoBmp, PolyPolygon& rPolyPoly, sal_uLong nFlags, const Link* pProgress ) { - Bitmap* pBmp = new Bitmap( rMonoBmp ); + boost::scoped_ptr<Bitmap> pBmp(new Bitmap( rMonoBmp )); BitmapReadAccess* pRAcc; - ImplVectMap* pMap; bool bRet = false; VECT_PROGRESS( pProgress, 10 ); @@ -759,17 +759,17 @@ bool ImplVectorizer::ImplVectorize( const Bitmap& rMonoBmp, VECT_PROGRESS( pProgress, 30 ); pRAcc = pBmp->AcquireReadAccess(); - pMap = ImplExpand( pRAcc, COL_BLACK ); + boost::scoped_ptr<ImplVectMap> pMap(ImplExpand( pRAcc, COL_BLACK )); pBmp->ReleaseAccess( pRAcc ); - delete pBmp; + pBmp.reset(); VECT_PROGRESS( pProgress, 60 ); if( pMap ) { rPolyPoly.Clear(); - ImplCalculate( pMap, rPolyPoly, 0, nFlags ); - delete pMap; + ImplCalculate( pMap.get(), rPolyPoly, 0, nFlags ); + pMap.reset(); ImplLimitPolyPoly( rPolyPoly ); if( nFlags & BMP_VECTORIZE_REDUCE_EDGES ) diff --git a/vcl/source/gdi/outdev4.cxx b/vcl/source/gdi/outdev4.cxx index 2422dc27ef77..88d23163d0ef 100644 --- a/vcl/source/gdi/outdev4.cxx +++ b/vcl/source/gdi/outdev4.cxx @@ -43,6 +43,7 @@ #include <basegfx/polygon/b2dpolygon.hxx> #include <basegfx/polygon/b2dpolypolygon.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> +#include <boost/scoped_ptr.hpp> #define HATCH_MAXPOINTS 1024 #define GRADIENT_DEFAULT_STEPCOUNT 0 @@ -363,7 +364,7 @@ void OutputDevice::ImplDrawComplexGradient( const Rectangle& rRect, // can print polygons on top of each other. // Also virtual devices are excluded, as some drivers are too slow. - PolyPolygon* pPolyPoly; + boost::scoped_ptr<PolyPolygon> pPolyPoly; Rectangle aRect; Point aCenter; Color aStartCol( rGradient.GetStartColor() ); @@ -383,9 +384,7 @@ void OutputDevice::ImplDrawComplexGradient( const Rectangle& rRect, rGradient.GetBoundRect( rRect, aRect, aCenter ); if( (meRasterOp != ROP_OVERPAINT) || (meOutDevType != OUTDEV_WINDOW) || bMtf ) - pPolyPoly = new PolyPolygon( 2 ); - else - pPolyPoly = NULL; + pPolyPoly.reset(new PolyPolygon( 2 )); long nMinRect = std::min( aRect.GetWidth(), aRect.GetHeight() ); @@ -484,7 +483,7 @@ void OutputDevice::ImplDrawComplexGradient( const Rectangle& rRect, aPoly.Rotate( aCenter, nAngle ); // adapt colour accordingly - const long nStepIndex = ( ( pPolyPoly != NULL ) ? i : ( i + 1 ) ); + const long nStepIndex = ( ( pPolyPoly ) ? i : ( i + 1 ) ); nRed = ImplGetGradientColorValue( nStartRed + ( ( nRedSteps * nStepIndex ) / nSteps ) ); nGreen = ImplGetGradientColorValue( nStartGreen + ( ( nGreenSteps * nStepIndex ) / nSteps ) ); nBlue = ImplGetGradientColorValue( nStartBlue + ( ( nBlueSteps * nStepIndex ) / nSteps ) ); @@ -554,8 +553,6 @@ void OutputDevice::ImplDrawComplexGradient( const Rectangle& rRect, ImplDrawPolygon( rPoly, pClipPolyPoly ); } } - - delete pPolyPoly; } } @@ -856,19 +853,19 @@ void OutputDevice::DrawGradient( const PolyPolygon& rPolyPoly, if( !aDstRect.IsEmpty() ) { - VirtualDevice* pVDev; + boost::scoped_ptr<VirtualDevice> pVDev; const Size aDstSize( aDstRect.GetSize() ); if( HasAlpha() ) { // #110958# Pay attention to alpha VDevs here, otherwise, // background will be wrong: Temp VDev has to have alpha, too. - pVDev = new VirtualDevice( *this, 0, GetAlphaBitCount() > 1 ? 0 : 1 ); + pVDev.reset(new VirtualDevice( *this, 0, GetAlphaBitCount() > 1 ? 0 : 1 )); } else { // nothing special here. Plain VDev - pVDev = new VirtualDevice(); + pVDev.reset(new VirtualDevice()); } if( pVDev->SetOutputSizePixel( aDstSize) ) @@ -894,8 +891,6 @@ void OutputDevice::DrawGradient( const PolyPolygon& rPolyPoly, EnableMapMode( bOldMap ); } - - delete pVDev; } } } diff --git a/vcl/source/gdi/outdev6.cxx b/vcl/source/gdi/outdev6.cxx index e61e6bf58f12..e7ee3b43396e 100644 --- a/vcl/source/gdi/outdev6.cxx +++ b/vcl/source/gdi/outdev6.cxx @@ -41,6 +41,7 @@ #include <basegfx/matrix/b2dhommatrix.hxx> #include <math.h> +#include <boost/scoped_ptr.hpp> namespace { @@ -679,10 +680,10 @@ void OutputDevice::DrawTransparent( const GDIMetaFile& rMtf, const Point& rPos, if( !aDstRect.IsEmpty() ) { - VirtualDevice* pVDev = new VirtualDevice; + boost::scoped_ptr<VirtualDevice> pVDev(new VirtualDevice); - ((OutputDevice*)pVDev)->mnDPIX = mnDPIX; - ((OutputDevice*)pVDev)->mnDPIY = mnDPIY; + ((OutputDevice*)pVDev.get())->mnDPIX = mnDPIX; + ((OutputDevice*)pVDev.get())->mnDPIY = mnDPIY; if( pVDev->SetOutputSizePixel( aDstRect.GetSize() ) ) { @@ -718,7 +719,7 @@ void OutputDevice::DrawTransparent( const GDIMetaFile& rMtf, const Point& rPos, // draw MetaFile to buffer pVDev->EnableMapMode(bBufferMapModeEnabled); ((GDIMetaFile&)rMtf).WindStart(); - ((GDIMetaFile&)rMtf).Play(pVDev, rPos, rSize); + ((GDIMetaFile&)rMtf).Play(pVDev.get(), rPos, rSize); ((GDIMetaFile&)rMtf).WindStart(); // get content bitmap from buffer @@ -733,7 +734,7 @@ void OutputDevice::DrawTransparent( const GDIMetaFile& rMtf, const Point& rPos, pVDev->EnableMapMode(false); const AlphaMask aAlpha(pVDev->GetBitmap(aPoint, pVDev->GetOutputSizePixel())); - delete pVDev; + pVDev.reset(); // draw masked content to target and restore MapMode DrawBitmapEx(aDstRect.TopLeft(), BitmapEx(aPaint, aAlpha)); @@ -753,7 +754,7 @@ void OutputDevice::DrawTransparent( const GDIMetaFile& rMtf, const Point& rPos, // create paint bitmap ( (GDIMetaFile&) rMtf ).WindStart(); - ( (GDIMetaFile&) rMtf ).Play( pVDev, rPos, rSize ); + ( (GDIMetaFile&) rMtf ).Play( pVDev.get(), rPos, rSize ); ( (GDIMetaFile&) rMtf ).WindStart(); pVDev->EnableMapMode( false ); aPaint = pVDev->GetBitmap( Point(), pVDev->GetOutputSizePixel() ); @@ -766,7 +767,7 @@ void OutputDevice::DrawTransparent( const GDIMetaFile& rMtf, const Point& rPos, pVDev->SetDrawMode( DRAWMODE_WHITELINE | DRAWMODE_WHITEFILL | DRAWMODE_WHITETEXT | DRAWMODE_WHITEBITMAP | DRAWMODE_WHITEGRADIENT ); ( (GDIMetaFile&) rMtf ).WindStart(); - ( (GDIMetaFile&) rMtf ).Play( pVDev, rPos, rSize ); + ( (GDIMetaFile&) rMtf ).Play( pVDev.get(), rPos, rSize ); ( (GDIMetaFile&) rMtf ).WindStart(); pVDev->EnableMapMode( false ); aMask = pVDev->GetBitmap( Point(), pVDev->GetOutputSizePixel() ); @@ -781,15 +782,13 @@ void OutputDevice::DrawTransparent( const GDIMetaFile& rMtf, const Point& rPos, aAlpha = pVDev->GetBitmap( Point(), pVDev->GetOutputSizePixel() ); - delete pVDev; + pVDev.reset(); EnableMapMode( false ); DrawBitmapEx( aDstRect.TopLeft(), BitmapEx( aPaint, aAlpha ) ); EnableMapMode( bOldMap ); } } - else - delete pVDev; } mpMetaFile = pOldMetaFile; diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx index b0410fec3d65..357cee4bef2f 100644 --- a/vcl/source/gdi/pdfwriter_impl2.cxx +++ b/vcl/source/gdi/pdfwriter_impl2.cxx @@ -40,6 +40,7 @@ #include "cppuhelper/implbase1.hxx" #include <rtl/digest.h> +#include <boost/scoped_ptr.hpp> using namespace vcl; using namespace rtl; @@ -249,10 +250,11 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa { bool bAssertionFired( false ); - VirtualDevice* pPrivateDevice = NULL; + boost::scoped_ptr<VirtualDevice> pPrivateDevice; if( ! pDummyVDev ) { - pPrivateDevice = pDummyVDev = new VirtualDevice(); + pPrivateDevice.reset(new VirtualDevice()); + pDummyVDev = pPrivateDevice.get(); pDummyVDev->EnableOutput( false ); pDummyVDev->SetMapMode( i_rMtf.GetPrefMapMode() ); } @@ -435,7 +437,7 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa if ( nPixelX && nPixelY ) { Size aDstSizePixel( nPixelX, nPixelY ); - VirtualDevice* pVDev = new VirtualDevice; + boost::scoped_ptr<VirtualDevice> pVDev(new VirtualDevice); if( pVDev->SetOutputSizePixel( aDstSizePixel ) ) { Bitmap aPaint, aMask; @@ -458,7 +460,7 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa // create paint bitmap aTmpMtf.WindStart(); - aTmpMtf.Play( pVDev, aPoint, aDstSize ); + aTmpMtf.Play( pVDev.get(), aPoint, aDstSize ); aTmpMtf.WindStart(); pVDev->EnableMapMode( false ); @@ -472,7 +474,7 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa pVDev->SetDrawMode( DRAWMODE_WHITELINE | DRAWMODE_WHITEFILL | DRAWMODE_WHITETEXT | DRAWMODE_WHITEBITMAP | DRAWMODE_WHITEGRADIENT ); aTmpMtf.WindStart(); - aTmpMtf.Play( pVDev, aPoint, aDstSize ); + aTmpMtf.Play( pVDev.get(), aPoint, aDstSize ); aTmpMtf.WindStart(); pVDev->EnableMapMode( false ); aMask = pVDev->GetBitmap( aPoint, aDstSizePixel ); @@ -487,7 +489,6 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa aAlpha = pVDev->GetBitmap( aPoint, aDstSizePixel ); implWriteBitmapEx( rPos, rSize, BitmapEx( aPaint, aAlpha ), pDummyVDev, i_rContext ); } - delete pVDev; } } } @@ -1063,8 +1064,6 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa i++; } } - - delete pPrivateDevice; } // Encryption methods 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" ); |