Kaydet (Commit) add367bf authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in swf::Writer

Change-Id: Ia337bffa45a1949567f70586db480d92bb55b238
Reviewed-on: https://gerrit.libreoffice.org/49936Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 55dd09e3
...@@ -93,8 +93,6 @@ Writer::Writer( sal_Int32 nTWIPWidthOutput, sal_Int32 nTWIPHeightOutput, sal_Int ...@@ -93,8 +93,6 @@ Writer::Writer( sal_Int32 nTWIPWidthOutput, sal_Int32 nTWIPHeightOutput, sal_Int
Writer::~Writer() Writer::~Writer()
{ {
mpVDev.disposeAndClear(); mpVDev.disposeAndClear();
delete mpSprite;
delete mpTag;
} }
...@@ -175,8 +173,8 @@ void Writer::storeTo( Reference< XOutputStream > const &xOutStream ) ...@@ -175,8 +173,8 @@ void Writer::storeTo( Reference< XOutputStream > const &xOutStream )
sal_uInt16 Writer::startSprite() sal_uInt16 Writer::startSprite()
{ {
sal_uInt16 nShapeId = createID(); sal_uInt16 nShapeId = createID();
mvSpriteStack.push(mpSprite); mvSpriteStack.push(mpSprite.release());
mpSprite = new Sprite( nShapeId ); mpSprite.reset(new Sprite( nShapeId ));
return nShapeId; return nShapeId;
} }
...@@ -189,15 +187,13 @@ void Writer::endSprite() ...@@ -189,15 +187,13 @@ void Writer::endSprite()
endTag(); endTag();
mpSprite->write( *mpMovieStream ); mpSprite->write( *mpMovieStream );
delete mpSprite; mpSprite.reset();
if (!mvSpriteStack.empty()) if (!mvSpriteStack.empty())
{ {
mpSprite = mvSpriteStack.top(); mpSprite.reset( mvSpriteStack.top() );
mvSpriteStack.pop(); mvSpriteStack.pop();
} }
else
mpSprite = nullptr;
} }
} }
...@@ -243,7 +239,7 @@ void Writer::startTag( sal_uInt8 nTagId ) ...@@ -243,7 +239,7 @@ void Writer::startTag( sal_uInt8 nTagId )
{ {
DBG_ASSERT( mpTag == nullptr, "Last tag was not ended"); 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() ...@@ -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) ) ) 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 ); mpSprite->addTag( mpTag.release() );
mpTag = nullptr;
} }
else else
{ {
mpTag->write( *mpMovieStream ); mpTag->write( *mpMovieStream );
delete mpTag; mpTag.reset();
mpTag = nullptr;
} }
} }
...@@ -329,7 +323,7 @@ sal_uInt16 Writer::defineShape( const tools::PolyPolygon& rPolyPoly, const FillS ...@@ -329,7 +323,7 @@ sal_uInt16 Writer::defineShape( const tools::PolyPolygon& rPolyPoly, const FillS
mpTag->addUI8( 1 ); // FillStyleCount mpTag->addUI8( 1 ); // FillStyleCount
// FILLSTYLE // FILLSTYLE
rFillStyle.addTo( mpTag ); rFillStyle.addTo( mpTag.get() );
// LINESTYLEARRAY // LINESTYLEARRAY
mpTag->addUI8( 0 ); // LineStyleCount mpTag->addUI8( 0 ); // LineStyleCount
......
...@@ -385,8 +385,8 @@ private: ...@@ -385,8 +385,8 @@ private:
typedef std::vector<sal_uInt16> CharacterIdVector; typedef std::vector<sal_uInt16> CharacterIdVector;
CharacterIdVector maShapeIds; CharacterIdVector maShapeIds;
Tag* mpTag; std::unique_ptr<Tag> mpTag;
Sprite* mpSprite; std::unique_ptr<Sprite> mpSprite;
std::stack<Sprite*> mvSpriteStack; std::stack<Sprite*> mvSpriteStack;
ChecksumCache mBitmapCache; ChecksumCache mBitmapCache;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment