summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Page <aptitude@btconnect.com>2016-06-29 07:28:22 +0100
committerNoel Grandin <noelgrandin@gmail.com>2016-07-01 13:05:20 +0000
commit663b7aec30703c8479c9dec2f8955bdc28bdca5e (patch)
treee9253fdb99f347bf3189eb14e005fb58465894d6
parent8e3451c096987e6fc7eaca409fd45a62e13ae4c5 (diff)
Modify the ImpGraphic class, mpAnimation to use a unique pointer
Change-Id: Icb2be06cf5476d4d04752ab2270fe1c58453fe8f Reviewed-on: https://gerrit.libreoffice.org/26791 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
-rw-r--r--vcl/inc/impgraph.hxx2
-rw-r--r--vcl/source/gdi/impgraph.cxx21
2 files changed, 7 insertions, 16 deletions
diff --git a/vcl/inc/impgraph.hxx b/vcl/inc/impgraph.hxx
index 884b6a6810e6..e5ba1e94e4ae 100644
--- a/vcl/inc/impgraph.hxx
+++ b/vcl/inc/impgraph.hxx
@@ -40,7 +40,7 @@ private:
GDIMetaFile maMetaFile;
BitmapEx maEx;
ImpSwapInfo maSwapInfo;
- Animation* mpAnimation;
+ std::unique_ptr<Animation> mpAnimation;
GraphicReader* mpContext;
std::shared_ptr<ImpSwapFile> mpSwapFile;
GfxLink* mpGfxLink;
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index ba92a25c2509..0f7eb2160e82 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -95,7 +95,6 @@ Size GraphicReader::GetPreviewSize() const
}
ImpGraphic::ImpGraphic() :
- mpAnimation ( nullptr ),
mpContext ( nullptr ),
mpGfxLink ( nullptr ),
meType ( GraphicType::NONE ),
@@ -126,11 +125,9 @@ ImpGraphic::ImpGraphic( const ImpGraphic& rImpGraphic ) :
if( rImpGraphic.mpAnimation )
{
- mpAnimation = new Animation( *rImpGraphic.mpAnimation );
+ mpAnimation = o3tl::make_unique<Animation>( *rImpGraphic.mpAnimation );
maEx = mpAnimation->GetBitmapEx();
}
- else
- mpAnimation = nullptr;
maSvgData = rImpGraphic.maSvgData;
maPdfData = rImpGraphic.maPdfData;
@@ -138,7 +135,6 @@ ImpGraphic::ImpGraphic( const ImpGraphic& rImpGraphic ) :
ImpGraphic::ImpGraphic( const Bitmap& rBitmap ) :
maEx ( rBitmap ),
- mpAnimation ( nullptr ),
mpContext ( nullptr ),
mpGfxLink ( nullptr ),
meType ( !rBitmap.IsEmpty() ? GraphicType::Bitmap : GraphicType::NONE ),
@@ -152,7 +148,6 @@ ImpGraphic::ImpGraphic( const Bitmap& rBitmap ) :
ImpGraphic::ImpGraphic( const BitmapEx& rBitmapEx ) :
maEx ( rBitmapEx ),
- mpAnimation ( nullptr ),
mpContext ( nullptr ),
mpGfxLink ( nullptr ),
meType ( !rBitmapEx.IsEmpty() ? GraphicType::Bitmap : GraphicType::NONE ),
@@ -180,7 +175,7 @@ ImpGraphic::ImpGraphic(const SvgDataPtr& rSvgDataPtr)
ImpGraphic::ImpGraphic( const Animation& rAnimation ) :
maEx ( rAnimation.GetBitmapEx() ),
- mpAnimation ( new Animation( rAnimation ) ),
+ mpAnimation ( o3tl::make_unique<Animation>( rAnimation ) ),
mpContext ( nullptr ),
mpGfxLink ( nullptr ),
meType ( GraphicType::Bitmap ),
@@ -194,7 +189,6 @@ ImpGraphic::ImpGraphic( const Animation& rAnimation ) :
ImpGraphic::ImpGraphic( const GDIMetaFile& rMtf ) :
maMetaFile ( rMtf ),
- mpAnimation ( nullptr ),
mpContext ( nullptr ),
mpGfxLink ( nullptr ),
meType ( GraphicType::GdiMetafile ),
@@ -223,16 +217,15 @@ ImpGraphic& ImpGraphic::operator=( const ImpGraphic& rImpGraphic )
meType = rImpGraphic.meType;
mnSizeBytes = rImpGraphic.mnSizeBytes;
- delete mpAnimation;
+ mpAnimation.reset();
if ( rImpGraphic.mpAnimation )
{
- mpAnimation = new Animation( *rImpGraphic.mpAnimation );
+ mpAnimation = o3tl::make_unique<Animation>( *rImpGraphic.mpAnimation );
maEx = mpAnimation->GetBitmapEx();
}
else
{
- mpAnimation = nullptr;
maEx = rImpGraphic.maEx;
}
@@ -337,8 +330,7 @@ void ImpGraphic::ImplClearGraphics( bool bCreateSwapInfo )
if( mpAnimation )
{
mpAnimation->Clear();
- delete mpAnimation;
- mpAnimation = nullptr;
+ mpAnimation.reset();
}
if( mpGfxLink )
@@ -1469,8 +1461,7 @@ SvStream& ReadImpGraphic( SvStream& rIStm, ImpGraphic& rImpGraphic )
if( !rIStm.GetError() && ( 0x5344414e == nMagic1 ) && ( 0x494d4931 == nMagic2 ) )
{
- delete rImpGraphic.mpAnimation;
- rImpGraphic.mpAnimation = new Animation;
+ rImpGraphic.mpAnimation = o3tl::make_unique<Animation>();
ReadAnimation( rIStm, *rImpGraphic.mpAnimation );
// #108077# manually set loaded BmpEx to Animation