diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-02-06 15:13:35 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-02-19 07:12:42 +0100 |
commit | add367bfec9d12502e64d2994f0f39e2e436442a (patch) | |
tree | a6eacac2082fe25306913a7c7008cc1232e97865 | |
parent | 55dd09e3e5867a0dbaca53b8a3425839e5210234 (diff) |
loplugin:useuniqueptr in swf::Writer
Change-Id: Ia337bffa45a1949567f70586db480d92bb55b238
Reviewed-on: https://gerrit.libreoffice.org/49936
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | filter/source/flash/swfwriter.cxx | 22 | ||||
-rw-r--r-- | filter/source/flash/swfwriter.hxx | 4 |
2 files changed, 10 insertions, 16 deletions
diff --git a/filter/source/flash/swfwriter.cxx b/filter/source/flash/swfwriter.cxx index d32c417d4362..071f567073e5 100644 --- a/filter/source/flash/swfwriter.cxx +++ b/filter/source/flash/swfwriter.cxx @@ -93,8 +93,6 @@ Writer::Writer( sal_Int32 nTWIPWidthOutput, sal_Int32 nTWIPHeightOutput, sal_Int Writer::~Writer() { mpVDev.disposeAndClear(); - delete mpSprite; - delete mpTag; } @@ -175,8 +173,8 @@ void Writer::storeTo( Reference< XOutputStream > const &xOutStream ) sal_uInt16 Writer::startSprite() { sal_uInt16 nShapeId = createID(); - mvSpriteStack.push(mpSprite); - mpSprite = new Sprite( nShapeId ); + mvSpriteStack.push(mpSprite.release()); + mpSprite.reset(new Sprite( nShapeId )); return nShapeId; } @@ -189,15 +187,13 @@ void Writer::endSprite() endTag(); mpSprite->write( *mpMovieStream ); - delete mpSprite; + mpSprite.reset(); if (!mvSpriteStack.empty()) { - mpSprite = mvSpriteStack.top(); + mpSprite.reset( mvSpriteStack.top() ); mvSpriteStack.pop(); } - else - mpSprite = nullptr; } } @@ -243,7 +239,7 @@ void Writer::startTag( sal_uInt8 nTagId ) { DBG_ASSERT( mpTag == nullptr, "Last tag was not ended"); - mpTag = new Tag( nTagId ); + mpTag.reset( new Tag( nTagId ) ); } @@ -253,14 +249,12 @@ void Writer::endTag() if( mpSprite && ( (nTag == TAG_END) || (nTag == TAG_SHOWFRAME) || (nTag == TAG_DOACTION) || (nTag == TAG_STARTSOUND) || (nTag == TAG_PLACEOBJECT) || (nTag == TAG_PLACEOBJECT2) || (nTag == TAG_REMOVEOBJECT2) || (nTag == TAG_FRAMELABEL) ) ) { - mpSprite->addTag( mpTag ); - mpTag = nullptr; + mpSprite->addTag( mpTag.release() ); } else { mpTag->write( *mpMovieStream ); - delete mpTag; - mpTag = nullptr; + mpTag.reset(); } } @@ -329,7 +323,7 @@ sal_uInt16 Writer::defineShape( const tools::PolyPolygon& rPolyPoly, const FillS mpTag->addUI8( 1 ); // FillStyleCount // FILLSTYLE - rFillStyle.addTo( mpTag ); + rFillStyle.addTo( mpTag.get() ); // LINESTYLEARRAY mpTag->addUI8( 0 ); // LineStyleCount diff --git a/filter/source/flash/swfwriter.hxx b/filter/source/flash/swfwriter.hxx index 7bb9d33b65cd..34982a1c588a 100644 --- a/filter/source/flash/swfwriter.hxx +++ b/filter/source/flash/swfwriter.hxx @@ -385,8 +385,8 @@ private: typedef std::vector<sal_uInt16> CharacterIdVector; CharacterIdVector maShapeIds; - Tag* mpTag; - Sprite* mpSprite; + std::unique_ptr<Tag> mpTag; + std::unique_ptr<Sprite> mpSprite; std::stack<Sprite*> mvSpriteStack; ChecksumCache mBitmapCache; |